This repository was archived by the owner on Apr 22, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
url: fix/8722 #8755
Closed
Closed
url: fix/8722 #8755
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1085,7 +1085,7 @@ var formatTests = { | |
|
||
// `#`,`?` in path | ||
'/path/to/%%23%3F+=&.txt?foo=theA1#bar' : { | ||
href : '/path/to/%%23%3F+=&.txt?foo=theA1#bar', | ||
href: '/path/to/%%23%3F+=&.txt?foo=theA1#bar', | ||
pathname: '/path/to/%#?+=&.txt', | ||
query: { | ||
foo: 'theA1' | ||
|
@@ -1095,7 +1095,7 @@ var formatTests = { | |
|
||
// `#`,`?` in path + `#` in query | ||
'/path/to/%%23%3F+=&.txt?foo=the%231#bar' : { | ||
href : '/path/to/%%23%3F+=&.txt?foo=the%231#bar', | ||
href: '/path/to/%%23%3F+=&.txt?foo=the%231#bar', | ||
pathname: '/path/to/%#?+=&.txt', | ||
query: { | ||
foo: 'the#1' | ||
|
@@ -1110,7 +1110,7 @@ var formatTests = { | |
hostname: 'ex.com', | ||
hash: '#frag', | ||
search: '?abc=the#1?&foo=bar', | ||
pathname: '/foo?100%m#r', | ||
pathname: '/foo?100%m#r' | ||
}, | ||
|
||
// `?` and `#` in search only | ||
|
@@ -1120,7 +1120,16 @@ var formatTests = { | |
hostname: 'ex.com', | ||
hash: '#frag', | ||
search: '?abc=the#1?&foo=bar', | ||
pathname: '/fooA100%mBr', | ||
pathname: '/fooA100%mBr' | ||
}, | ||
|
||
// only for path rather than pathname | ||
'http://github.com/joyent/node#js': { | ||
href: 'http://github.com/joyent/node#js', | ||
protocol: 'http:', | ||
hostname: 'github.com', | ||
hash: '#js', | ||
path: '/joyent/node' | ||
} | ||
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. Hey @chrisdickinson, please review the above 5 tests from here, it follows your diagram and description: |
||
}; | ||
for (var u in formatTests) { | ||
|
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.
If path is given:
query
query
is usedsearch
is given, it always winshash
is given, it always winsI suppose my confusion is: for some attributes, the more specific attribute "wins" versus the more general attribute, while in the "path" case, the less specific version wins:
query is more specific than search is more specific than path -> search wins
pathname is more specific than path -> path wins
hash is more specific than path -> hash wins
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.
hey @chrisdickinson they are not consistent because you say:
i guess in hash line, it should be "path wins"?
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.
and for given pseudocode by last last comment, in
path
case, we should only touch one ofquery
orsearch
, because inpath
they are overlapped, so i choosequery
,search
will be reassigned next code, so i propose the program will be:query
query
is used of course includedsearch
hash
hash
is usedfrom my above statement, i guess we shouldn't touch
search
any more, just follow the step 1.@chrisdickinson how do you think about my idea?
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.
Hm. I think we should try to mirror how
host
(vs.hostname
+port
) operates withpath
-- that is:If
path
is given, it is assumed to includesearch
/query
andpathname
. If those are not present inpath
, andpath
is given, then they will be omitted from the output offormat
.So:
to illustrate:
Setting a key at the higher level should cause
url.format
to ignore all keys at a "lower" level, whether or not that lower key is present in the text of the higher level key (even though "port" may not be present in "host", setting "host" ignores all values for "port").