You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current specs only handle host canonicalization for IP addresses and opaque hostnames but if an URL has a special scheme its host should be normalized as a domain name (IDNA processing).
Cf. whatwg#220
Copy file name to clipboardExpand all lines: spec.bs
+19-7
Original file line number
Diff line number
Diff line change
@@ -472,6 +472,7 @@ A <dfn>component</dfn> is a [=struct=] with the following [=struct/items=]:
472
472
1. Set |urlPattern|'s [=URL pattern/username component=] to the result of [=compiling a component=] given |processedInit|["{{URLPatternInit/username}}"], [=canonicalize a username=], and [=default options=].
473
473
1. Set |urlPattern|'s [=URL pattern/password component=] to the result of [=compiling a component=] given |processedInit|["{{URLPatternInit/password}}"], [=canonicalize a password=], and [=default options=].
474
474
1. If the result running [=hostname pattern is an IPv6 address=] given |processedInit|["{{URLPatternInit/hostname}}"] is true, then set |urlPattern|'s [=URL pattern/hostname component=] to the result of [=compiling a component=] given |processedInit|["{{URLPatternInit/hostname}}"], [=canonicalize an IPv6 hostname=], and [=hostname options=].
475
+
1. Otherwise, if the result of running [=protocol component matches a special scheme=] given |urlPattern|'s [=URL pattern/protocol component=] is true, or |urlPattern|'s [=URL pattern/protocol component=]'s [=component/pattern string=] is "`*`", then set |urlPattern|'s [=URL pattern/hostname component=] to the result of [=compiling a component=] given |processedInit|["{{URLPatternInit/hostname}}"], [=canonicalize a domain name=], and [=hostname options=].
475
476
1. Otherwise, set |urlPattern|'s [=URL pattern/hostname component=] to the result of [=compiling a component=] given |processedInit|["{{URLPatternInit/hostname}}"], [=canonicalize a hostname=], and [=hostname options=].
476
477
1. Set |urlPattern|'s [=URL pattern/port component=] to the result of [=compiling a component=] given |processedInit|["{{URLPatternInit/port}}"], [=canonicalize a port=], and [=default options=].
477
478
1. Let |compileOptions| be a copy of the [=default options=] with the [=options/ignore case=] property set to |options|["{{URLPatternOptions/ignoreCase}}"].
@@ -1729,15 +1730,23 @@ To <dfn>convert a modifier to a string</dfn> given a [=part/modifier=] |modifier
1729
1730
</div>
1730
1731
1731
1732
<div algorithm>
1732
-
To <dfn>canonicalize a hostname</dfn> given a string |value|:
1733
+
To <dfn>canonicalize a hostname</dfn> given a string |value| and optionally a string |protocolValue|:
1733
1734
1734
1735
1. If |value| is the empty string, return |value|.
1735
1736
1. Let |dummyURL| be a new [=URL record=].
1737
+
1. If |protocolValue| was given, then set |dummyURL|'s [=url/scheme=] to |protocolValue|.
1738
+
<p class="note">We set the [=URL record=]'s [=url/scheme=] in order for the [=basic URL parser=] to recognize and normalize non-opaque hostname values.</p>
1736
1739
1. Let |parseResult| be the result of running the [=basic URL parser=] given |value| with |dummyURL| as <i>[=basic URL parser/url=]</i> and [=hostname state=] as <i>[=basic URL parser/state override=]</i>.
1737
1740
1. If |parseResult| is failure, then throw a {{TypeError}}.
1738
1741
1. Return |dummyURL|'s [=url/host=], [=host serializer|serialized=], or empty string if it is null.
1739
1742
</div>
1740
1743
1744
+
<div algorithm>
1745
+
To <dfn>canonicalize a domain name</dfn> given a string |value|:
1746
+
1747
+
1. Return the result of running [=canonicalize a hostname=] given |value| and "`https`".
1748
+
</div>
1749
+
1741
1750
<div algorithm>
1742
1751
To <dfn>canonicalize an IPv6 hostname</dfn> given a string |value|:
1743
1752
@@ -1869,7 +1878,7 @@ To <dfn>convert a modifier to a string</dfn> given a [=part/modifier=] |modifier
1869
1878
1. If |init|["{{URLPatternInit/protocol}}"][=map/exists=], then set |result|["{{URLPatternInit/protocol}}"] to the result of [=process protocol for init=] given |init|["{{URLPatternInit/protocol}}"] and |type|.
1870
1879
1. If |init|["{{URLPatternInit/username}}"][=map/exists=], then set |result|["{{URLPatternInit/username}}"] to the result of [=process username for init=] given |init|["{{URLPatternInit/username}}"] and |type|.
1871
1880
1. If |init|["{{URLPatternInit/password}}"][=map/exists=], then set |result|["{{URLPatternInit/password}}"] to the result of [=process password for init=] given |init|["{{URLPatternInit/password}}"] and |type|.
1872
-
1. If |init|["{{URLPatternInit/hostname}}"][=map/exists=], then set |result|["{{URLPatternInit/hostname}}"] to the result of [=process hostname for init=] given |init|["{{URLPatternInit/hostname}}"] and |type|.
1881
+
1. If |init|["{{URLPatternInit/hostname}}"][=map/exists=], then set |result|["{{URLPatternInit/hostname}}"] to the result of [=process hostname for init=] given |init|["{{URLPatternInit/hostname}}"], |result|["{{URLPatternInit/protocol}}"], and |type|.
1873
1882
1. If |init|["{{URLPatternInit/port}}"][=map/exists=], then set |result|["{{URLPatternInit/port}}"] to the result of [=process port for init=] given |init|["{{URLPatternInit/port}}"], |result|["{{URLPatternInit/protocol}}"], and |type|.
1874
1883
1. If |init|["{{URLPatternInit/pathname}}"][=map/exists=]:
1875
1884
1. Set |result|["{{URLPatternInit/pathname}}"] to |init|["{{URLPatternInit/pathname}}"].
@@ -1935,10 +1944,12 @@ To <dfn>convert a modifier to a string</dfn> given a [=part/modifier=] |modifier
1935
1944
</div>
1936
1945
1937
1946
<div algorithm>
1938
-
To <dfn>process hostname for init</dfn> given a string |value| and a string |type|:
1947
+
To <dfn>process hostname for init</dfn> given a string |hostnameValue|, a string |protocolValue|, and a string |type|:
1939
1948
1940
-
1. If |type| is "`pattern`" then return |value|.
1941
-
1. Return the result of running [=canonicalize a hostname=] given |value|.
1949
+
1. If |type| is "`pattern`" then return |hostnameValue|.
1950
+
1. If |protocolValue| is a [=special scheme=] or the empty string, then return the result of running [=canonicalize a domain name=] given |hostnameValue|.
1951
+
<p class="note">If the |protocolValue| is the empty string then no value was provided for {{URLPatternInit/protocol}} in the constructor dictionary. Normally we do not special case empty string dictionary values, but in this case we treat it as a [=special scheme=] in order to default to the most common hostname canonicalization.</p>
1952
+
1. Return the result of running [=canonicalize a hostname=] given |hostnameValue|.
1942
1953
</div>
1943
1954
1944
1955
<div algorithm>
@@ -2113,8 +2124,9 @@ Ralph Chelala,
2113
2124
Sangwhan Moon,
2114
2125
Sayan Pal,
2115
2126
Victor Costan,
2116
-
Yoshisato Yanagisawa, and
2117
-
Youenn Fablet
2127
+
Yoshisato Yanagisawa,
2128
+
Youenn Fablet, and
2129
+
Yves-Marie K. Rinquin
2118
2130
for their contributors to this specification.
2119
2131
2120
2132
Special thanks to Blake Embrey and the other [pillarjs/path-to-regexp](https://github.com/pillarjs/path-to-regexp) [contributors](https://github.com/pillarjs/path-to-regexp/graphs/contributors) for building an excellent open source library that so many have found useful.
0 commit comments