-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fix a bug with url encoded parameters in url.parse #1480
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ describe('helpers.url', () => { | |
let parsed; | ||
|
||
beforeEach(() => { | ||
parsed = parse('http://example.com:3000/pathname/?search=test&foo=bar#hash'); | ||
parsed = parse('http://example.com:3000/pathname/?search=test&foo=bar&bar=foo%26foo%3Dxxx#hash'); | ||
}); | ||
|
||
it('extracts the protocol', () => { | ||
|
@@ -28,8 +28,9 @@ describe('helpers.url', () => { | |
it('extracts the search query', () => { | ||
expect(parsed).to.have.property('search'); | ||
expect(parsed.search).to.eql({ | ||
foo: 'bar', | ||
search: 'test' | ||
foo: 'xxx', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I left this here to show that the current |
||
search: 'test', | ||
bar: 'foo', | ||
}); | ||
}); | ||
|
||
|
@@ -42,16 +43,33 @@ describe('helpers.url', () => { | |
}); | ||
}); | ||
|
||
describe('parse(url, {noDecodeWholeURL: true})', () => { | ||
let parsed; | ||
|
||
beforeEach(() => { | ||
parsed = parse('http://example.com:3000/pathname/?search=test&foo=bar&bar=foo%26foo%3Dxxx#hash', {noDecodeWholeURL: true}); | ||
}); | ||
|
||
it('extracts the search query', () => { | ||
expect(parsed).to.have.property('search'); | ||
expect(parsed.search).to.eql({ | ||
foo: 'bar', | ||
search: 'test', | ||
bar: 'foo%26foo%3Dxxx', | ||
}); | ||
}); | ||
}); | ||
|
||
describe('format()', () => { | ||
it('formats an object in to a URL', () => { | ||
expect(format({ | ||
protocol: 'http', | ||
hostname: 'example.com', | ||
port: 3000, | ||
pathname: '/pathname/', | ||
search: {foo: 'bar', search: 'test'}, | ||
search: {foo: 'bar', search: 'test', bar: 'foo%26foo%3Dxxx'}, | ||
hash: 'hash' | ||
})).to.equal('http://example.com:3000/pathname/?foo=bar&search=test#hash'); | ||
})).to.equal('http://example.com:3000/pathname/?foo=bar&search=test&bar=foo%26foo%3Dxxx#hash'); | ||
}); | ||
|
||
it('will use defaults for missing properties', () => { | ||
|
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.
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.
Not sure if passing the whole
options
object here is the best or if it should extract the options that apply tourl.parse
. This would result in a lot more code.