-
Notifications
You must be signed in to change notification settings - Fork 177
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
[RFC] URL-encode path parameters for Router.url #116
Merged
Merged
Conversation
This file contains 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
3imed-jaberi
approved these changes
Mar 6, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sgtm
0xvbetsun
approved these changes
Dec 10, 2021
The main breaking change from v8.x to v9.x was an upgrade to `path-to-regex`. [That PR](koajs#71) alluded to a breaking change in encoding. Namely, parameters were not URL-encoded: parameters with safe special characters (like spaces) were not percent-encoded, and parameters with special characters that mean something in a URL, such as slashes (path separators) and question marks (query string delimiter). The motivation for this PR is to make URL-encoding be the default since typically the parameters provided to `Router.url` are plain, unencoded values. Should someone need an escape hatch, they could pass in `{ encode: null }` (I think) to disable the automatic encoding. Updated tests and docs.
ide
force-pushed
the
@ide/encode-component-default
branch
from
July 18, 2022 22:49
ca7bee0
to
f754976
Compare
@titanism would you be interested in taking a look at this change? In summary, it fixes query parameter escaping for |
https://github.com/koajs/router/releases/tag/v12.0.0 mirrored to |
1 task
This was referenced Sep 8, 2024
This was referenced Sep 16, 2024
This was referenced Sep 20, 2024
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.
This is a proposal for a public API change.
The main breaking change from v8.x to v9.x was an upgrade to
path-to-regex
. That PR alluded to a breaking change in encoding. Namely, parameters were not URL-encoded: parameters with safe special characters (like spaces) were not percent-encoded, and parameters with special characters that mean something in a URL, such as slashes (path separators) and question marks (query string delimiter).The motivation for this PR is to make URL-encoding be the default since typically the parameters provided to
Router.url
are plain, unencoded values. Should someone need an escape hatch, they could pass in{ encode: null }
(I think) to disable the automatic encoding.This addition to the changelog shows the change by example:
Router.url
withencodeURIComponent
.Router.url('/:x', { x: 'hello world' })
produced"/hello world"
Router.url('/:x', { x: 'a/test?param#' })
would throw an errorRouter.url('/:x', { x: 'hello world' })
produces"/hello%20world"
Router.url('/:x', { x: 'a/test?param#' })
produces"/a%2Ftest%3Fparam%23"
Updated tests, docs, and the changelog.