Fix decoding entire pathname edge cases#192
Merged
sindresorhus merged 4 commits intosindresorhus:mainfrom Jun 9, 2025
Merged
Conversation
Contributor
Author
|
It looks like a rate limit was hit with Codecov for the Node.js 16 checks. Also, I don't see the option to "Allow edits from maintainers”. Maybe the checks have to pass first? |
sindresorhus
reviewed
Jun 6, 2025
sindresorhus
reviewed
Jun 8, 2025
test.js
Outdated
Comment on lines
43
to
45
| t.is(normalizeUrl('https://foo.com/some%5Bthing%5Celse/that-is%40great@coding'), 'https://foo.com/some[thing%5Celse/that-is%40great@coding'); | ||
| t.is(normalizeUrl('https://foo.com/something\\else/great'), 'https://foo.com/something/else/great'); | ||
| t.is(normalizeUrl('https://foo.com/something%5Celse/great'), 'https://foo.com/something%5Celse/great'); |
Owner
There was a problem hiding this comment.
Would be better to have this in a separate test with a clear title, so it's easier to see what's being tested.
1 task
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.
Fixes #191
One caveat with this change is that all invalid/reserved URI characters will now be encoded. This is necessary to prevent something like
\from appearing and then v8 flipping that to a/. This URL is an example of how things go wrong with%5Cbeing decoded to\, then getting flipped to/by theURLclass. This is a valid URL that you can visit in your browser to see the image.https://tourpic-vector.maps.komoot.net/r/big/u%60t%5Be_pC~EzKnI%60p@h@nf@xFzJeB~EdQdXbH%60e@pHvOsAxp@lO%60VnA%7CVvyAhnAbYff@~P~ItT%5CjNjm@%7CQtU/?width=768&height=576&crop=true
However, if you run it through
normalize-url, it will no longer map to the same resource on Komoot. Instead, you end up with this URL.https://tourpic-vector.maps.komoot.net/r/big/u%60t[e_pC~EzKnI%60p@h@nf@xFzJeB~EdQdXbH%60e@pHvOsAxp@lO%60VnA%7CVvyAhnAbYff@~P~ItT/jNjm@%7CQtU/?width=768&height=576&crop=true