Freecodecamp: User profile URL is case sensitive

Created on 15 Oct 2018  路  24Comments  路  Source: freeCodeCamp/freeCodeCamp

When trying to view a users profile, the URL is case sensitive.

https://www.freecodecamp.org/mot01 - works
https://www.freecodecamp.org/moT01 - doesn't work

It would be nice if it could ignore the case sensitivity somehow, if possible.

api client UI on the roadmap feature request

Most helpful comment

@QuincyLarson I will start working on this issue. Is there any way that you could assign this issue to me on the Github? I do not want to do any duplicate work with other contributors so that we could all work efficiently. Thank you.

All 24 comments

In my opinion, that's a bad idea. would allow for less usernames that are not complex

Best practices call for usernames to be unique, It only calls for serverside validation as the usernames are being fetched, the requests can then be lowercased despite the case in which they are input by the user.

Not sure how usernames are stored, but seems like they are all stored in lowercase.
If possible, perhaps we can lowercase the letters before querying the database?

@ezioda004 but that could be a problem for some people who have same usernames but the letters cases are different
For example

NirajN would be stored as nirajn

But

Nirajn will also be stored as nirajn

@Nirajn2311 That shouldnt be a problem, fcc doesnt allow 2 same usernames with different case sensitivity.
If NirajN exists then one cannot take Nirajn or nirajn, you can test this out in the settings menu (change username validator).
So, it does look like the names are indeed stored as lowercases, so querying the DB with lowercase shouldn't be a problem.

There's no point doing so. As if you wanted to use the username in capital letters, then lowercase won't be supported and vice-versa.

@dkcr7 I don't understand what you are getting at, no point in doing what?

I'm sure I signed up as RaspberryLime, but fCC displays it in lowercase instead. I think that when checking to see if a username is available when signing up or changing a username that it should be a case insensitive search (so there isn't RaspberryLime and raspberrylime), but otherwise the user should be able to choose the capitalisation they want.

It would be nice if the system could identify that someone has typed in
say https://www.freecodecamp.org/raspberrylime to their URL bar and then switch them to
https://www.freecodecamp.org/RaspberryLime instead.

I completely agree with @RaspberryLime . I would like to contribute to this issue! I am planning on taking the input URL (doesn't matter whether the username is correctly capitalized or not) and if the username case doesn't match, then redirect it to the correct URL only if there is a matching username. However, if the username doesn't exist, then the current behaviour will stay in effect.

What do you think @QuincyLarson ?

@moT01 Thanks for pointing this out. Yes - I agree - we should fix this.

@addv12345 Yes - we would welcome your help with this!

We want for the database query to be case-insensitive. We also want to store the case-sensitive version of usernames for display both in the URL and on the profile itself. This is how GitHub, Twitter, and many other services operate.

Twitter example:
bri_bri_ _on_twitter___someone_sent_me_a_thank_you_note_for_helping_to_inspire_them__she_comes_to_the_javascript_study_group_every_thursday__this_just_made_my_day_ _https___t_co_aiuapfmtgf_

@QuincyLarson I will start working on this issue. Is there any way that you could assign this issue to me on the Github? I do not want to do any duplicate work with other contributors so that we could all work efficiently. Thank you.

@addv12345 I can't assign it to you through GitHub (I think you have to have write permissions for me to do that) but I've set it to "in progress". Please keep us posted and if you need any help, we're here for you in https://gitter.im/freecodecamp/contributors

Hi @QuincyLarson

Some of the requirements here are not trivial, because of our legacy user model schema. That is somethings about the model if not planned from the beginning always make your system resistive to change.

Anyways I will leave some pointers for anyone working on this:

While this is fixable, major changes like this may not be the best for the larger scope of the project. So, this needs extensive testing unless we want to end up with hundreds of support emails for the way a username appears.

This saga handles the profile request:
https://github.com/freeCodeCamp/freeCodeCamp/blob/db02d1c479812d6cc18e9c31094d5dde434a91be/client/src/redux/fetch-user-saga.js#L30-L42

The maybeUser argument should be enforced to be lower case.

@raisedadead Thanks for the details. Since this is a relatively low priority, I'll add it to the roadmap and we can tackle it later.

Hi! @QuincyLarson My friend @addv12345 and I are still potentially interested in this issue. However, we are new to this project. Would it still be worth investigating this particular problem?

Would it still be worth investigating this particular problem?

Yes, sure. We are interested in fixing this. However, as I said before this needs extensive testing and the solution has to be elegant enough to play well with our current schema. We have put up all the pointers in the previous comments.

Please feel free to dig in, and let us know if you need additional information on working thru this.

Thanks.

Sounds good and thank you for your help! @addv12345 and I were looking into it earlier. The issue we ran into was that we could not find a way to test the code or access a user's public profile (or a mock user's profile - not sure how that part is structured yet). Can you please point us in the right direction?

Sure.

Once you setup freeCodeCamp locally, you should have already seeded (a.k.a populated) the database using the guide.

The current way of reaching the user profile page is bit tedious (because we have Gatsby's dev server taking over in local development).

Here is what you should do:

Then on, I would recommend using a GUI DB tools like Robo 3T, and tweak your user(s) / add more user objects etc. as you please.

Feel free to hit us up on Contributors Chat room or DM me as well.

Thanks for working on this and goodluck!

@raisedadead I tried to run some commands on mongodb locally, and I actually noticed that the username is stored in the original format. Am I looking in the right place?
image

@icatat It is stored that way in the db, so that it displays as the user originally entered it.

@icatat That is more an implementation of the Development User. this record should insert the user with the correct casing of the username also.

@icatat @addv12345 I have created a fresh request for the requirement, since it differs from the original issue.

@raisedadead Thank you very much! We will look into the new issue then!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

robwelan picture robwelan  路  3Comments

raisedadead picture raisedadead  路  3Comments

imhuyqn picture imhuyqn  路  3Comments

SaintPeter picture SaintPeter  路  3Comments

DaphnisM picture DaphnisM  路  3Comments