From 2208476e7930577b83ae0076db83bd5fac4dc5b1 Mon Sep 17 00:00:00 2001 From: Ben Kelly Date: Thu, 2 Sep 2021 18:50:46 +0000 Subject: [PATCH] Support pattern syntax in ipv6 hostnames. (Fixes #115) --- spec.bs | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/spec.bs b/spec.bs index 799800b..019360f 100644 --- a/spec.bs +++ b/spec.bs @@ -280,7 +280,8 @@ Each {{URLPattern}} object has an associated hash component< 1. Set [=this=]'s [=URLPattern/protocol component=] to the result of [=compiling a component=] given |processedInit|["{{URLPatternInit/protocol}}"], [=canonicalize a protocol=], and [=default options=]. 1. Set [=this=]'s [=URLPattern/username component=] to the result of [=compiling a component=] given |processedInit|["{{URLPatternInit/username}}"], [=canonicalize a username=], and [=default options=]. 1. Set [=this=]'s [=URLPattern/password component=] to the result of [=compiling a component=] given |processedInit|["{{URLPatternInit/password}}"], [=canonicalize a password=], and [=default options=]. - 1. Set [=this=]'s [=URLPattern/hostname component=] to the result of [=compiling a component=] given |processedInit|["{{URLPatternInit/hostname}}"], [=canonicalize a hostname=], and [=hostname options=]. + 1. If the result running [=hostname pattern is an IPv6 address=] given |processedInit|["{{URLPatternInit/hostname}}"] is true, then set [=this=]'s [=URLPattern/hostname component=] to the result of [=compiling a component=] given |processedInit|["{{URLPatternInit/hostname}}"], [=canonicalize an IPv6 hostname=], and [=hostname options=]. + 1. Else, set [=this=]'s [=URLPattern/hostname component=] to the result of [=compiling a component=] given |processedInit|["{{URLPatternInit/hostname}}"], [=canonicalize a hostname=], and [=hostname options=]. 1. Set [=this=]'s [=URLPattern/port component=] to the result of [=compiling a component=] given |processedInit|["{{URLPatternInit/port}}"], [=canonicalize a port=], and [=default options=]. 1. If the result of running [=protocol component matches a special scheme=] given [=this=]'s [=URLPattern/protocol component=] is true, then set [=this=]'s [=URLPattern/pathname component=] to the result of [=compiling a component=] given |processedInit|["{{URLPatternInit/pathname}}"], [=canonicalize a pathname=], and [=pathname options=]. 1. Else set [=this=]'s [=URLPattern/pathname component=] to the result of [=compiling a component=] given |processedInit|["{{URLPatternInit/pathname}}"], [=canonicalize a cannot-be-a-base-URL pathname=], and [=default options=] @@ -464,6 +465,16 @@ The pathname options is an [=options=] [=struct=] with [=options/deli 1. Return false. +
+ To determine if a hostname pattern is an IPv6 address given a [=/pattern string=] |input|: + + 1. If |input|'s [=string/code point length=] is less than 2, then return false. + 1. If |input|[0] is U+005B (`[`), then return true. + 1. If |input|[0] is U+007B (`{`) and |input|[1] is U+005B (`[`), then return true. + 1. If |input|[0] is U+005C (\) and |input|[1] is U+005B (`[`), then return true. + 1. Return false. +
+

Constructor String Parsing

A constructor string parser is a [=struct=]. @@ -1522,6 +1533,23 @@ To convert a modifier to a string given a [=part/modifier=] |modifier 1. Return |dummyURL|'s [=url/host=]. +
+ To canonicalize an IPv6 hostname given a string |value|: + + 1. Let |result| be the empty string. + 1. [=list/For each=] |code point| in |value| interpreted as a sequence of [=/code points=]: + 1. If all of the following are true: +
    +
  • |code point| is not an [=ASCII hex digit=];
  • +
  • |code point| is not U+005B (`[`);
  • +
  • |code point| is not U+005D (`]`); and
  • +
  • |code point| is not U+003A (`:`),
  • +
+

then throw a {{TypeError}}. + 1. Append the result of running [=ASCII lowercase=] given "|code point|" to the end of |result|. + 1. Return |result|. +

+
To canonicalize a port given a string |portValue| and optionally a string |protocolValue|: