This repository has been archived by the owner on Dec 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 970
Fix discrepancy between node url.parse and muon.url.parse #13916
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,10 +173,10 @@ module.exports = { | |
|
||
'isFileType': { | ||
'relative file': (test) => { | ||
test.equal(urlUtil().isFileType('/file/abc/test.pdf', 'pdf'), true) | ||
test.equal(urlUtil().isFileType('file:///file/abc/test.pdf', 'pdf'), true) | ||
}, | ||
'relative path': (test) => { | ||
test.equal(urlUtil().isFileType('/file/abc/test', 'pdf'), false) | ||
test.equal(urlUtil().isFileType('file:///file/abc/test', 'pdf'), false) | ||
}, | ||
'JPG URL': (test) => { | ||
test.equal(urlUtil().isFileType('http://example.com/test/ABC.JPG?a=b#test', 'jpg'), true) | ||
|
@@ -365,7 +365,7 @@ module.exports = { | |
test.strictEqual(urlUtil().getOrigin('https://abc.bing.com'), 'https://abc.bing.com') | ||
}, | ||
'gets URL origin for url with port': (test) => { | ||
test.strictEqual(urlUtil().getOrigin('https://bing.com:443/?test=1#abc'), 'https://bing.com:443') | ||
test.strictEqual(urlUtil().getOrigin('https://bing.com:8000/?test=1#abc'), 'https://bing.com:8000') | ||
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. this test was failing in muon because muon gets the origin from GURL.GetOrigin (https://cs.chromium.org/chromium/src/url/gurl.h?q=gurl&sq=package:chromium&l=201), which doesn't return the port if it's 443 for HTTPS or 80 for HTTP |
||
}, | ||
'gets URL origin for IP host': (test) => { | ||
test.strictEqual(urlUtil().getOrigin('http://127.0.0.1:443/?test=1#abc'), 'http://127.0.0.1:443') | ||
|
@@ -374,7 +374,11 @@ module.exports = { | |
test.strictEqual(urlUtil().getOrigin('about:preferences#abc'), 'about:preferences') | ||
}, | ||
'gets URL origin for slashless protocol URL': (test) => { | ||
test.strictEqual(urlUtil().getOrigin('about:test'), 'about:test') | ||
test.strictEqual(urlUtil().getOrigin('about:test/'), 'about:test') | ||
test.strictEqual(urlUtil().getOrigin('about:test/foo'), 'about:test') | ||
test.strictEqual(urlUtil().getOrigin('about:test/foo/bar'), 'about:test') | ||
test.strictEqual(urlUtil().getOrigin('about:test/foo/bar#baz'), 'about:test') | ||
}, | ||
'returns null for invalid URL': (test) => { | ||
test.strictEqual(urlUtil().getOrigin('abc'), null) | ||
|
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.
Is
parsed.path
always a string, and never null / undefined? I'm guessing so if the test cases without path are working...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.
@petemill this code only runs for muon.url.parse, where parsed.origin is not undefined. in that case, path is always a string.