URLPattern: Adjust pathname canonicalization based on protocol. #28154
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.
This CL refines the pathname canonicalization routines to account for
differences between "standard" URLs and what chrome calls "path" URLs.
"Path" URLs are referred to as "cannot-be-a-base" URLs in the spec.
To choose the canonicalization routine we look at the protocol pattern
or string. If the protocol matches a "standard" scheme, then we choose
"standard" canonicalization. We also ensure that empty string protocol
values default to "standard" canonicalization. Otherwise we use the
"path" URL canonicalization which is more lenient; e.g. it makes it
easier to write javascript: URL paths, etc.
This CL also exposes two new functions from the url component:
schemes. We need this in order to match them against our protocol
pattern. For example,
http{s}?
should match as a standard protocolpattern since it matches both
http
andhttps
. We can't use theIsStandard() function for this so we need to expose the whole list to
iterate and check against.
routine for "path" URLs. Previously only a full url parsing function
was exposed.
Discussed in:
whatwg/urlpattern#33
Bug: 1141510
Change-Id: I3176a36d1e0eb2f8a0ccdf65fde346a4a623f9dd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2769358
Commit-Queue: Ben Kelly <wanderview@chromium.org>
Reviewed-by: Charlie Harrison <csharrison@chromium.org>
Reviewed-by: Jeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#865276}