From 015499266555de1c970503986e402a686c61b110 Mon Sep 17 00:00:00 2001 From: Yoshisato Yanagisawa Date: Thu, 29 Feb 2024 09:21:36 +0900 Subject: [PATCH] Make the match algorithm accept the URL struct 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. --- spec.bs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/spec.bs b/spec.bs index d36abb2..876b22e 100644 --- a/spec.bs +++ b/spec.bs @@ -468,7 +468,7 @@ A component is a [=struct=] with the following [=struct/items=]:
- To perform a match given a [=URL pattern=] |urlPattern|, a {{URLPatternInput}} |input|, and an optional string |baseURLString|: + To perform a match 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. @@ -492,13 +492,16 @@ A component 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=].