-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
URLPattern: Implement compareComponent() method.
This CL adds a prototype URLPattern.compareComponent() to provide a natural ordering to URLPattern pattern strings. This was based on feedback from routing framework authors and there is some discussion in: whatwg/urlpattern#61 The general algorithm is to compare the component patterns Part by Part. The PartType, Modifier, and text contents are compared for each Part, but group names are not considered. The end result is a mostly lexicographical ordering based on fixed text. Matching groups and modifiers are ordered such that more restrictive patterns are greater. Bug: 1232795 Change-Id: I8474cd7d7689e657c9c74c552ad630cdcdd86c95 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3052630 Commit-Queue: Ben Kelly <[email protected]> Reviewed-by: Jeremy Roman <[email protected]> Cr-Commit-Position: refs/heads/master@{#906025} NOKEYCHECK=True GitOrigin-RevId: 22c632e87d6a2113f28ecff375e2d5b6f69c9710
- Loading branch information
1 parent
5a2e841
commit 367e336
Showing
17 changed files
with
341 additions
and
27 deletions.
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
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
116 changes: 116 additions & 0 deletions
116
blink/web_tests/external/wpt/urlpattern/resources/urlpattern-compare-test-data.json
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 |
---|---|---|
@@ -0,0 +1,116 @@ | ||
[ | ||
{ | ||
"component": "pathname", | ||
"left": { "pathname": "/foo/a" }, | ||
"right": { "pathname": "/foo/b" }, | ||
"expected": -1 | ||
}, | ||
{ | ||
"component": "pathname", | ||
"left": { "pathname": "/foo/b" }, | ||
"right": { "pathname": "/foo/bar" }, | ||
"expected": -1 | ||
}, | ||
{ | ||
"component": "pathname", | ||
"left": { "pathname": "/foo/bar" }, | ||
"right": { "pathname": "/foo/:bar" }, | ||
"expected": 1 | ||
}, | ||
{ | ||
"component": "pathname", | ||
"left": { "pathname": "/foo/" }, | ||
"right": { "pathname": "/foo/:bar" }, | ||
"expected": 1 | ||
}, | ||
{ | ||
"component": "pathname", | ||
"left": { "pathname": "/foo/:bar" }, | ||
"right": { "pathname": "/foo/*" }, | ||
"expected": 1 | ||
}, | ||
{ | ||
"component": "pathname", | ||
"left": { "pathname": "/foo/{bar}" }, | ||
"right": { "pathname": "/foo/(bar)" }, | ||
"expected": 1 | ||
}, | ||
{ | ||
"component": "pathname", | ||
"left": { "pathname": "/foo/{bar}" }, | ||
"right": { "pathname": "/foo/{bar}+" }, | ||
"expected": 1 | ||
}, | ||
{ | ||
"component": "pathname", | ||
"left": { "pathname": "/foo/{bar}+" }, | ||
"right": { "pathname": "/foo/{bar}?" }, | ||
"expected": 1 | ||
}, | ||
{ | ||
"component": "pathname", | ||
"left": { "pathname": "/foo/{bar}?" }, | ||
"right": { "pathname": "/foo/{bar}*" }, | ||
"expected": 1 | ||
}, | ||
{ | ||
"component": "pathname", | ||
"left": { "pathname": "/foo/(123)" }, | ||
"right": { "pathname": "/foo/(12)" }, | ||
"expected": 1 | ||
}, | ||
{ | ||
"component": "pathname", | ||
"left": { "pathname": "/foo/:b" }, | ||
"right": { "pathname": "/foo/:a" }, | ||
"expected": 0 | ||
}, | ||
{ | ||
"component": "pathname", | ||
"left": { "pathname": "*/foo" }, | ||
"right": { "pathname": "*" }, | ||
"expected": 1 | ||
}, | ||
{ | ||
"component": "port", | ||
"left": { "port": "9" }, | ||
"right": { "port": "100" }, | ||
"expected": 1 | ||
}, | ||
{ | ||
"component": "pathname", | ||
"left": { "pathname": "foo/:bar?/baz" }, | ||
"right": { "pathname": "foo/{:bar}?/baz" }, | ||
"expected": -1 | ||
}, | ||
{ | ||
"component": "pathname", | ||
"left": { "pathname": "foo/:bar?/baz" }, | ||
"right": { "pathname": "foo{/:bar}?/baz" }, | ||
"expected": 0 | ||
}, | ||
{ | ||
"component": "pathname", | ||
"left": { "pathname": "foo/:bar?/baz" }, | ||
"right": { "pathname": "fo{o/:bar}?/baz" }, | ||
"expected": 1 | ||
}, | ||
{ | ||
"component": "pathname", | ||
"left": { "pathname": "foo/:bar?/baz" }, | ||
"right": { "pathname": "foo{/:bar/}?baz" }, | ||
"expected": -1 | ||
}, | ||
{ | ||
"component": "pathname", | ||
"left": "https://a.example.com/b?a", | ||
"right": "https://b.example.com/a?b", | ||
"expected": 1 | ||
}, | ||
{ | ||
"component": "pathname", | ||
"left": { "pathname": "/foo/{bar}/baz" }, | ||
"right": { "pathname": "/foo/bar/baz" }, | ||
"expected": 0 | ||
} | ||
] |
Oops, something went wrong.