Skip to content

Commit

Permalink
Make the match algorithm accept the URL struct
Browse files Browse the repository at this point in the history
In w3c/ServiceWorker#1701, the ServiceWorker static routing API uses the match algorithm to match the request URL. However, the original match algorithm accepts a URLPatternInput object, and it does not accept a URL struct. To allow the ServiceWorker static routing API to use the match algorithm, we need to make the match algorithm to accept the URL struct.

Fixes: #218.
  • Loading branch information
yoshisatoyanagisawa authored Feb 29, 2024
1 parent 8b8ac40 commit 0154992
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions spec.bs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ A <dfn>component</dfn> is a [=struct=] with the following [=struct/items=]:
</div>

<div algorithm>
To perform a <dfn export for="URL pattern">match</dfn> given a [=URL pattern=] |urlPattern|, a {{URLPatternInput}} |input|, and an optional string |baseURLString|:
To perform a <dfn export for="URL pattern">match</dfn> given a [=URL pattern=] |urlPattern|, a {{URLPatternInput}} or [=/URL=] |input|, and an optional string |baseURLString|:

1. Let |protocol| be the empty string.
1. Let |username| be the empty string.
Expand All @@ -492,13 +492,16 @@ A <dfn>component</dfn> is a [=struct=] with the following [=struct/items=]:
1. Set |search| to |applyResult|["{{URLPatternInit/search}}"].
1. Set |hash| to |applyResult|["{{URLPatternInit/hash}}"].
1. Otherwise:
1. Let |baseURL| be null.
1. If |baseURLString| was given, then:
1. Set |baseURL| to the result of [=URL parser|parsing=] |baseURLString|.
1. If |baseURL| is failure, return null.
1. [=list/Append=] |baseURLString| to |inputs|.
1. Let |url| be the result of [=URL parser|parsing=] |input| given |baseURL|.
1. If |url| is failure, return null.
1. Let |url| be |input|.
1. If |input| is a {{USVString}}:
1. Let |baseURL| be null.
1. If |baseURLString| was given, then:
1. Set |baseURL| to the result of [=URL parser|parsing=] |baseURLString|.
1. If |baseURL| is failure, return null.
1. [=list/Append=] |baseURLString| to |inputs|.
1. Set |url| to the result of [=URL parser|parsing=] |input| given |baseURL|.
1. If |url| is failure, return null.
1. [=Assert=]: |url| is a [=/URL=].
1. Set |protocol| to |url|'s [=url/scheme=].
1. Set |username| to |url|'s [=url/username=].
1. Set |password| to |url|'s [=url/password=].
Expand Down

0 comments on commit 0154992

Please sign in to comment.