Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Router.push/replace ignores trailing spaces on the last query parameter (even if encoded as %20) #10009

Closed
renato opened this issue Jan 9, 2020 · 4 comments · Fixed by #10102
Labels
kind: bug Confirmed bug that is on the backlog Upstream Related to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.).
Milestone

Comments

@renato
Copy link

renato commented Jan 9, 2020

Bug report

Describe the bug

Router.push/replace ignores trailing spaces on the last query parameter, even if already encoded (%20). Examples:

  • Router.push("/?q=unencoded trailing ") results in query = { "q": "unencoded trailing" }
  • Router.push(encodeURI("/?q=encoded trailing ")) results in query = { "q": "encoded trailing" }
  • Router.push({ pathname: "/", query: { q: "unencoded trailing " } }) results in query = { "q": "unencoded trailing" }
  • Router.push("/?q=unencoded trailing &add=trailing ") results in query = { "q": "unencoded trailing ", "add": "trailing" } (only the last param got stripped)

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. git clone https://github.com/renato/nextjs-using-router-trailing-space
  2. npm install
  3. npm run dev
  4. Navigate through links

Expected behavior

The query object should consistently have the complete string, with the trailing spaces, even for the last parameter.

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • OS: macOS 10.14.6
  • Browser: Chrome 79.0.3945.88
  • Version of Next.js: latest

Additional context

I don't know exactly what version changed the behavior, but this issue didn't happen some months ago.

@Timer Timer modified the milestones: 9.2.x, 9.2.0 Jan 10, 2020
@Timer
Copy link
Member

Timer commented Jan 14, 2020

This behavior changed in 9.1.5, working in 9.1.4.

@Timer Timer added priority: high kind: bug Confirmed bug that is on the backlog and removed Type: Needs Investigation labels Jan 14, 2020
@Timer
Copy link
Member

Timer commented Jan 15, 2020

04a7f1e is the first bad commit (long bisect process)

@Timer
Copy link
Member

Timer commented Jan 15, 2020

Upstream bug: GoogleChromeLabs/native-url#12

@Timer Timer added Upstream Related to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.). and removed priority: high labels Jan 15, 2020
@Timer Timer modified the milestones: 9.2.0, 9.2.1 Jan 15, 2020
@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind: bug Confirmed bug that is on the backlog Upstream Related to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants