diff --git a/index.bs b/index.bs
index 1ccfd5704..05733e57f 100644
--- a/index.bs
+++ b/index.bs
@@ -7841,7 +7841,7 @@ To get the network intercepts given |session|, |event|, |request|, an
1. For each |url pattern| in |url patterns|:
- 1. If [=match URL pattern=] with |url pattern| and |url|:
+ 1. If [=URL pattern/match|URL pattern match=] with |url pattern| and |url|:
1. [=list/Append=] |intercept id| to |intercepts|.
@@ -8859,14 +8859,13 @@ network.UrlPattern = (
network.UrlPatternPattern = {
type: "pattern",
- ?protocol: text,
- ?hostname: text,
- ?port: text,
- ?pathname: text,
- ?search: text,
+ ? protocol: text,
+ ? hostname: text,
+ ? port: text,
+ ? pathname: text,
+ ? search: text,
}
-
network.UrlPatternString = {
type: "string",
pattern: text,
@@ -8874,297 +8873,57 @@ network.UrlPatternString = {
-A network.UrlPattern represents a pattern used for matching request
-URLs for [=network intercepts=].
-
-When URLs are matched against a network.UrlPattern the URL is
-parsed, and each component is compared for equality with the corresponding field
-in the pattern, if present. Missing fields from the pattern always match.
-
-Note: This syntax is designed with future extensibility in mind. In particular
-the syntax forbids characters that are treated specially in the [[URLPattern]]
-specification. These can be escaped by prefixing them with a U+005C (\) character.
-
-
baseURL, username, password,
+hash) and parse options (e.g. ignoreCase).
- 1. Set |is escaped character| to false.
-
-1. Return [=success=] with data |result|.
+A network.UrlPattern represents a pattern used for matching request
+URLs for [=network intercepts=]. URL patterns use the syntax and semantics
+defined by [[!URLPattern]].
-network.UrlPatternPattern and the
+pattern field of network.UrlPatternString are parsed
+using [[!URLPattern]] syntax. Characters such as *,
++, ?, :, and
+{...} have special meaning as wildcards, modifiers,
+named groups, and grouping constructs respectively. To match these characters
+literally, prefix them with a backslash.
network.UrlPatternPattern production:
- 1. Let |pattern url| be the empty string.
-
- 1. If |pattern| [=map/contains=] "protocol":
-
- 1. If |pattern|["protocol"] is the empty string, return [=error=]
- with [=error code=] [=invalid argument=].
-
- 1. Let |protocol| be the result of [=trying=] to [=unescape
- URL Pattern=] with |pattern|["protocol"].
-
- 1. For each |codepoint| in |protocol|:
-
- 1. If |codepoint| is not [=ASCII alphanumeric=] and «U+002B (+), U+002D
- (-), U+002E (.)» does not [=set/contains|contain=] |codepoint|:
-
- 1. Return [=error=] with [=error code=] invalid argument.
-
- 1. Append |protocol| to |pattern url|.
-
- 1. Otherwise:
-
- 1. Set |has protocol| to false.
-
- 1. Append "http" to |pattern url|.
-
- 1. Let |scheme| be [=ASCII lowercase=] with |pattern url|.
-
- 1. Append ":" to |pattern url|.
-
- 1. If |scheme| [=is special=], append "//" to |pattern url|.
-
- 1. If |pattern| [=map/contains=] "hostname":
-
- 1. If |pattern|["hostname"] is the empty string, return [=error=]
- with [=error code=] [=invalid argument=].
-
- 1. If |scheme| is "file" return [=error=] with [=error code=]
- [=invalid argument=].
-
- 1. Let |hostname| be the result of [=trying=] to [=unescape
- URL Pattern=] with |pattern|["hostname"].
-
- 1. Let |inside brackets| be false.
-
- 1. For each |codepoint| in |hostname|:
-
- 1. If «U+002F (/), U+003F (?), U+0023 (#)» [=set/contains=]
- |codepoint|:
-
- 1. Return [=error=] with [=error code=] [=invalid argument=].
-
- 1. If |inside brackets| is false and |codepoint| is U+003A (:):
-
- 1. Return [=error=] with [=error code=] [=invalid argument=].
-
- 1. If |codepoint| is U+005B ([), set |inside brackets| to true.
-
- 1. If |codepoint| is U+005D (]), set |inside brackets| to false.
-
- 1. Append |hostname| to |pattern url|.
-
- 1. Otherwise:
-
- 1. If |scheme| is not "file", append "placeholder" to
- |pattern url|.
-
- 1. Set |has hostname| to false.
-
- 1. If |pattern| [=map/contains=] "port":
-
- 1. If |pattern|["port"] is the empty string, return [=error=]
- with [=error code=] [=invalid argument=].
-
- 1. Let |port| be the result of [=trying=] to [=unescape
- URL Pattern=] with |pattern|["port"].
-
- 1. Append ":" to |pattern url|.
-
- 1. For each |codepoint| in |port|:
-
- 1. If |codepoint| is not an [=ASCII digit=]:
+ 1. Let |init| be a new {{URLPatternInit}}.
- 1. Return [=error=] with [=error code=] [=invalid argument=].
+ 1. If |pattern| [=map/contains=] "protocol", set
+ |init|["protocol"] to |pattern|["protocol"].
- 1. Append |port| to |pattern url|.
+ 1. If |pattern| [=map/contains=] "hostname", set
+ |init|["hostname"] to |pattern|["hostname"].
- 1. Otherwise:
-
- 1. Set |has port| to false.
-
- 1. If |pattern| [=map/contains=] "pathname":
-
- 1. Let |pathname| be the result of [=trying=] to [=unescape URL Pattern=] with
- |pattern|["pathname"].
-
- 1. If |pathname| does not [=string/starts with|start with=] U+002F (/), then
- append "/" to |pattern url|.
-
- 1. For each |codepoint| in |pathname|:
-
- 1. If «U+003F (?), U+0023 (#)» [=set/contains=]
- |codepoint|:
-
- 1. Return [=error=] with [=error code=] [=invalid argument=].
-
- 1. Append |pathname| to |pattern url|.
-
- 1. Otherwise:
-
- 1. Set |has pathname| to false.
-
- 1. If |pattern| [=map/contains=] "search":
-
- 1. Let |search| be the result of [=trying=] to [=unescape URL pattern=] with
- |pattern|["search"].
-
- 1. If |search| does not [=string/starts with|start with=] U+003F (?), then
- append "?" to |pattern url|.
-
- 1. For each |codepoint| in |search|:
+ 1. If |pattern| [=map/contains=] "port", set
+ |init|["port"] to |pattern|["port"].
- 1. If |codepoint| is U+0023 (#):
+ 1. If |pattern| [=map/contains=] "pathname", set
+ |init|["pathname"] to |pattern|["pathname"].
- 1. Return [=error=] with [=error code=] [=invalid argument=].
+ 1. If |pattern| [=map/contains=] "search", set
+ |init|["search"] to |pattern|["search"].
- 1. Append |search| to |pattern url|.
-
- 1. Otherwise:
-
- 1. Set |has search| to false.
+ 1. Let |url pattern| be the result of
+ [=URL pattern/create|creating a URLPattern=] given |init|, null, and an
+ empty [=/map=]. If this throws an exception, return [=error=] with
+ [=error code=] [=invalid argument=].
1. Otherwise, if |pattern| matches the network.UrlPatternString production:
- 1. Let |pattern url| be the result of [=trying=] to [=unescape URL
- pattern=] with |pattern|["pattern"].
-
-1. Let |url| be the result of [=URL Parser|parsing=] |pattern url|.
-
-1. If |url| is failure, return [=error=] with [=error code=] [=invalid argument=].
-
-1. Let |parsed| be a struct with the following fields:
- pattern"], null, and an empty [=/map=]. If
+ this throws an exception, return [=error=] with [=error code=]
+ [=invalid argument=].
- 1. null.
-
-