From d13ebead18003059a83ca4a25240e5cafc066c4c Mon Sep 17 00:00:00 2001 From: "Yves-Marie K. Rinquin" Date: Fri, 19 Apr 2024 16:41:23 +0200 Subject: [PATCH] Editorial: Add proper serialization of URL properties The URL parser return port as an integer and host as either a hostname string, an integer (IPv4 address) or an array of integers (IPv6 address). For further processing by the URLPattern code these properties need to be properly converted to string. The issue was discussed here: #202 --- spec.bs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spec.bs b/spec.bs index 5d0ca8a..4fc708a 100644 --- a/spec.bs +++ b/spec.bs @@ -22,6 +22,7 @@ spec: ECMASCRIPT; urlPrefix: https://tc39.es/ecma262/ spec: URL; urlPrefix: https://url.spec.whatwg.org/ type: dfn text: serialize an integer; url: #serialize-an-integer + text: host serializer; url: #concept-host-serializer

URL patterns

@@ -506,8 +507,8 @@ A component is a [=struct=] with the following [=struct/items=]: 1. Set |protocol| to |url|'s [=url/scheme=]. 1. Set |username| to |url|'s [=url/username=]. 1. Set |password| to |url|'s [=url/password=]. - 1. Set |hostname| to |url|'s [=url/host=] or the empty string if the value is null. - 1. Set |port| to |url|'s [=url/port=] or the empty string if the value is null. + 1. Set |hostname| to |url|'s [=url/host=], [=host serializer|serialized=], or the empty string if the value is null. + 1. Set |port| to |url|'s [=url/port=], [=serialize an integer|serialized=], or the empty string if the value is null. 1. Set |pathname| to the result of [=URL path serializing=] |url|. 1. Set |search| to |url|'s [=url/query=] or the empty string if the value is null. 1. Set |hash| to |url|'s [=url/fragment=] or the empty string if the value is null. @@ -1726,7 +1727,7 @@ To convert a modifier to a string given a [=part/modifier=] |modifier 1. Let |dummyURL| be a new [=URL record=]. 1. Let |parseResult| be the result of running the [=basic URL parser=] given |value| with |dummyURL| as [=basic URL parser/url=] and [=hostname state=] as [=basic URL parser/state override=]. 1. If |parseResult| is failure, then throw a {{TypeError}}. - 1. Return |dummyURL|'s [=url/host=]. + 1. Return |dummyURL|'s [=url/host=], [=host serializer|serialized=], or empty string if it is null.
@@ -1749,7 +1750,7 @@ To convert a modifier to a string given a [=part/modifier=] |modifier
To canonicalize a port given a string |portValue| and optionally a string |protocolValue|: - 1. If |value| is the empty string, return |value|. + 1. If |portValue| is the empty string, return |portValue|. 1. Let |dummyURL| be a new [=URL record=]. 1. If |protocolValue| was given, then set |dummyURL|'s [=url/scheme=] to |protocolValue|.

Note, we set the [=URL record=]'s [=url/scheme=] in order for the [=basic URL parser=] to recognize and normalize default port values.