Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support pattern syntax in ipv6 hostnames. (Fixes #115) #116

Merged
merged 1 commit into from
Sep 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion spec.bs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ Each {{URLPattern}} object has an associated <dfn for=URLPattern>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=]
Expand Down Expand Up @@ -465,6 +466,17 @@ The <dfn>pathname options</dfn> is an [=options=] [=struct=] with [=options/deli
1. Return false.
</div>

<div algorithm>
To determine if a <dfn>hostname pattern is an IPv6 address</dfn> given a [=/pattern string=] |input|:

1. If |input|'s [=string/code point length=] is less than 2, then return false.
1. Let |input code points| be |input| interpreted as a [=list=] of [=/code points=].
1. If |input code points|[0] is U+005B (`[`), then return true.
1. If |input code points|[0] is U+007B (`{`) and |input code points|[1] is U+005B (`[`), then return true.
1. If |input code points|[0] is U+005C (<code>\</code>) and |input code points|[1] is U+005B (`[`), then return true.
1. Return false.
</div>

<h3 id=constructor-string-parsing>Constructor String Parsing</h3>

A <dfn export>constructor string parser</dfn> is a [=struct=].
Expand Down Expand Up @@ -1527,6 +1539,23 @@ To <dfn>convert a modifier to a string</dfn> given a [=part/modifier=] |modifier
1. Return |dummyURL|'s [=url/host=].
</div>

<div algorithm>
To <dfn>canonicalize an IPv6 hostname</dfn> given a string |value|:

1. Let |result| be the empty string.
1. [=list/For each=] |code point| in |value| interpreted as a [=list=] of [=/code points=]:
1. If all of the following are true:
<ul>
<li>|code point| is not an [=ASCII hex digit=];</li>
<li>|code point| is not U+005B (`[`);</li>
<li>|code point| is not U+005D (`]`); and</li>
<li>|code point| is not U+003A (`:`),</li>
</ul>
<p>then throw a {{TypeError}}.
1. Append the result of running [=ASCII lowercase=] given |code point| to the end of |result|.
1. Return |result|.
</div>

<div algorithm>
To <dfn>canonicalize a port</dfn> given a string |portValue| and optionally a string |protocolValue|:

Expand Down