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 doesn't handle query params correctly #190

Closed
brtinney opened this issue Oct 11, 2022 · 0 comments · Fixed by #196
Closed

Router doesn't handle query params correctly #190

brtinney opened this issue Oct 11, 2022 · 0 comments · Fixed by #196

Comments

@brtinney
Copy link

The fix in #77/#78 doesn't quite work correctly.

    const queryUrlIndex = path.lastIndexOf('?')
    if (queryUrlIndex > -1) {
      path = path.substring(0, queryUrlIndex)
    }

If your URL looks like /login?returnTo=/path?foo=bar, it will try to match on /login?returnTo=/path and fail. Because the current solution prioritizes the ability to use an invalid character for a route path (?), we get into this weird situation. An easy fix would just be going to the first ?, instead, since as soon as that character is reached, the path has been terminated.

In running nuxt in dev mode, this isn't an issue if I just escape the query string (which I do), but due to how the unjs/nitro handler is providing the URL to the router (it is using withQuery), the query string gets unescaped already. Double-encoding the query string means that it works figuring out the correct handler, but then breaks when trying to read that query string in the handler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant