Repository: freeCodeCamp/freeCodeCamp
File: api/src/routes/public/user.ts (TypeScript)

Code before:
    showDonation,
    showLocation,
    showName,
    showPoints,
    showPortfolio,
    showExperience,
    showTimeLine
  } = user.profileUI;

  return {
    about: showAbout ? user.about : '',
    calendar: showHeatMap ? user.calendar : {},
    completedChallenges: showTimeLine
      ? showCerts
        ? user.completedChallenges
        : user.completedChallenges.filter(
            c => c.challengeType !== challengeTypes.step
          )
      : [],
    isDonating: showDonation ? user.isDonating : null,
    joinDate: showAbout ? user.joinDate : '',
    location: showLocation ? user.location : '',
    name: showName ? user.name : '',
    points: showPoints ? user.points : null,
    portfolio: showPortfolio ? user.portfolio : [],
    experience: showExperience ? user.experience.map(e => removeNulls(e)) : []
  };
};

const blockedUserAgentParts = ['python', 'google-apps-script', 'curl'];
/**
 * Plugin containing public GET routes for user account management. They are kept
 * separate because they do not require CSRF protection or authorization.
 *
 * @param fastify The Fastify instance.
 * @param _options Options passed to the plugin via `fastify.register(plugin, options)`.
 * @param done Callback to signal that the logic has completed.
 */
export const userPublicGetRoutes: FastifyPluginCallbackTypebox = (
  fastify,
  _options,
  done
) => {
  fastify.get(
    '/users/get-public-profile',
    {
      schema: schemas.getPublicProfile,
      onRequest: (req, reply, done) => {
        const userAgent = req.headers['user-agent'];

        if (

Review comment (suggestion):
```suggestion
    experience: showExperience ? user.experience : []
```
This is taken care of before calling `replacePrivateData`, so that it has one job: removing data based on privacy settings.

Code after:
    showDonation,
    showLocation,
    showName,
    showPoints,
    showPortfolio,
    showExperience,
    showTimeLine
  } = user.profileUI;

  return {
    about: showAbout ? user.about : '',
    calendar: showHeatMap ? user.calendar : {},
    completedChallenges: showTimeLine
      ? showCerts
        ? user.completedChallenges
        : user.completedChallenges.filter(
            c => c.challengeType !== challengeTypes.step
          )
      : [],
    isDonating: showDonation ? user.isDonating : null,
    joinDate: showAbout ? user.joinDate : '',
    location: showLocation ? user.location : '',
    name: showName ? user.name : '',
    points: showPoints ? user.points : null,
    portfolio: showPortfolio ? user.portfolio : [],
    experience: showExperience ? user.experience : []
  };
};

const blockedUserAgentParts = ['python', 'google-apps-script', 'curl'];
/**
 * Plugin containing public GET routes for user account management. They are kept
 * separate because they do not require CSRF protection or authorization.
 *
 * @param fastify The Fastify instance.
 * @param _options Options passed to the plugin via `fastify.register(plugin, options)`.
 * @param done Callback to signal that the logic has completed.
 */
export const userPublicGetRoutes: FastifyPluginCallbackTypebox = (
  fastify,
  _options,
  done
) => {
  fastify.get(
    '/users/get-public-profile',
    {
      schema: schemas.getPublicProfile,
      onRequest: (req, reply, done) => {
        const userAgent = req.headers['user-agent'];

        if (