fix: handle URL-encoded @me in /users/:user_id route#1526
Open
xqliu wants to merge 1 commit intospacebarchat:masterfrom
Open
fix: handle URL-encoded @me in /users/:user_id route#1526xqliu wants to merge 1 commit intospacebarchat:masterfrom
xqliu wants to merge 1 commit intospacebarchat:masterfrom
Conversation
When clients URL-encode the @ character, /users/%40me is routed to /users/:user_id instead of the literal /users/@me route. Add the same @me → req.user_id substitution that other :user_id routes already have (e.g. profile.ts, voice-states). Fixes spacebarchat#1525
Member
|
Is this AI-generated...? |
Contributor
Member
Member
|
Oh wait, i see the logic now behind picking the "wrong" directory now... but i'm also not sure if this is the right fix, given this would probably affect hundreds of other endpoints. |
Contributor
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
/users/%40mereturns 404 because%40me(URL-encoded@me) is routed to/users/:user_idinstead of the literal/users/@meroute%40→@, soreq.params.user_idbecomes"@me", but the handler passes it directly toUser.getPublicUser()which fails@me → req.user_idsubstitution that other:user_idroutes already have (e.g.profile.ts,voice-states)Fixes #1525
Test plan
GET /users/%40mereturns the authenticated user (same asGET /users/@me)GET /users/<snowflake>still works as before/users/@me/literal route still works