Repository navigation
Conversation
sendResponse always built "${url}?${qs}", so withQs() or forwarded
query strings gave "/users?page=2?success=1" when the target already had
a query string, and "/users#list?success=1" when it had a fragment.
Join with "&" when the url already has a "?", and keep the fragment at
the end.
Fixes adonisjs#157
5 tasks done
This branch has not been deployed
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.
🔗 Linked issue
Fixes #157
❓ Type of change
📚 Description
Redirect#sendResponsealways built${url}?${qs}. So when the target url already had a query string or a fragment, the result was broken:With a second
?the browser readspageas2?success=1. After#the query string is part of the fragment and never reaches the server. The same happens withresponse.redirect(url, true)andforwardQueryString: true.Now the query string goes before the
#, and is joined with&when the url already has a?(no extra&if the url ends with?or&). Urls without a query string or fragment are built the same as before.Tests: added two tests in
tests/redirect.spec.ts. Both fail on9.xand pass with the fix.npm run lint,npm run typecheckandnpm run quick:test(675 tests) pass.📝 Checklist