From 7f77861ca03c2c7bfd6d190c5797a13cf3faa4ad Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Fri, 9 Dec 2022 11:37:07 +0100 Subject: [PATCH 1/2] Expose a URLHost class to JavaScript Tests: ... --- url.bs | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/url.bs b/url.bs index 8ad40e2d..66b89980 100644 --- a/url.bs +++ b/url.bs @@ -3502,6 +3502,54 @@ e.g., "newURL" and "oldURL". examples of proper naming. [[!HTML]] +

URLHost class

+ +
+[Exposed=*]
+interface URLHost {
+  constructor(USVString host);
+
+  readonly attribute URLHostType type;
+
+  stringifier USVString toJSON();
+};
+
+enum URLHostType { "ipv4", "ipv6", "domain" };
+ +

Each {{URLHost}} object has an associated host (a host). + +


+ +

The URLHost(input) constructor steps +are: + +

    +
  1. Let host be the result of host parsing input with true. + +

  2. If host is failure, then throw a {{TypeError}}. + +

  3. Return a new {{URLHost}} object whose host is host. +

+ +

The type getter steps are: + +

    +
  1. If this's host is an IPv4 address, then return + "ipv4". + +

  2. If this's host is an IPv6 address, then return + "ipv6". + +

  3. Assert: this's host is a domain. + +

  4. Return "domain". +

+ +

The stringification behavior and +toJSON() method steps, are to return this's +host, serialized. + +

Acknowledgments

@@ -3614,7 +3662,8 @@ Wei Wang, Wolf Lammen, 山岸和利 (Yamagishi Kazutoshi), Yongsheng Zhang, -成瀬ゆい (Yui Naruse), and +成瀬ゆい (Yui Naruse), +Zach Lym, and zealousidealroll for being awesome! From e7677bf8d01f81eb85afeb0b769ea8ddc1f8276e Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Fri, 9 Dec 2022 11:42:17 +0100 Subject: [PATCH 2/2] modernize --- url.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/url.bs b/url.bs index 66b89980..18a7c7dc 100644 --- a/url.bs +++ b/url.bs @@ -3528,7 +3528,7 @@ are:
  • If host is failure, then throw a {{TypeError}}. -

  • Return a new {{URLHost}} object whose host is host. +

  • Set this's host to host.

    The type getter steps are: