Discourse does not show the Real Name on a topic page then it (wrongly) assumes it is the same as the Username

AI-generated summary

Issue with Displaying Real Name on Discourse Topic Page

dmitry_fedyuk has identified an issue where Discourse does not display a user’s real name on a topic page if it is too similar to their username. This is due to the sanitizeName method in poster-name.js.es6, which removes spaces, hyphens, and underscores from the name before comparison.

dmitry_fedyuk proposes two possible solutions:

  1. Allowing users to disable this sanitation
  2. Modifying the sanitizeName method to only convert the name to lowercase and trim whitespace

However, codinghorror states that this behavior is “correct and as designed.”

downey disagrees, calling the design “horrible” and points to a previous discussion on the topic.

User has set the Real Name:

But Discourse does not show the Real Name because it assumes it too similar to the Username

The problem code is https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/components/poster-name.js.es6#L40

if (name && this.get('displayNameOnPosts') && (this.sanitizeName(name) !== this.sanitizeName(username))) {

And sanitize method is defined as: https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/components/poster-name.js.es6#L7

  // sanitize name for comparison
  sanitizeName(name){
    return name.toLowerCase().replace(/[\s_-]/g,'');
  },

I think it could be better the one of:

  • have possibility to disable such sanitation
  • recode sanitize method as
  // sanitize name for comparison
  sanitizeName(name){
    return name.toLowerCase().trim();
  },
6개의 좋아요

This is correct and as designed.

1개의 좋아요

Agreed; this is a horrible design and nobody likes it. :stuck_out_tongue:

See previous discussion:

4개의 좋아요