Skip to content

Commit

Permalink
Expose a URLHost class to JavaScript
Browse files Browse the repository at this point in the history
Tests: ...
  • Loading branch information
annevk committed Dec 9, 2022
1 parent 15a2dc9 commit 7f77861
Showing 1 changed file with 50 additions and 1 deletion.
51 changes: 50 additions & 1 deletion url.bs
Original file line number Diff line number Diff line change
Expand Up @@ -3502,6 +3502,54 @@ e.g., "newURL" and "oldURL".
examples of proper naming. [[!HTML]]


<h3 id=urlhost-class>URLHost class</h3>

<pre class=idl>
[Exposed=*]
interface URLHost {
constructor(USVString host);

readonly attribute URLHostType type;

stringifier USVString toJSON();
};

enum URLHostType { "ipv4", "ipv6", "domain" };</pre>

<p>Each {{URLHost}} object has an associated <dfn for=URLHost>host</dfn> (a <a for=/>host</a>).

<hr>

<p>The <dfn constructor for=URLHost><code>URLHost(<var>input</var>)</code></dfn> constructor steps
are:

<ol>
<li><p>Let <var>host</var> be the result of <a>host parsing</a> <var>input</var> with true.

<li><p>If <var>host</var> is failure, then <a>throw</a> a {{TypeError}}.

<li><p>Return a new {{URLHost}} object whose <a for=URLHost>host</a> is <var>host</var>.
</ol>

<p>The <dfn attribute for=URLHost><code>type</code></dfn> getter steps are:

<ol>
<li><p>If <a>this</a>'s <a for=URLHost>host</a> is an <a>IPv4 address</a>, then return
"<code>ipv4</code>".

<li><p>If <a>this</a>'s <a for=URLHost>host</a> is an <a>IPv6 address</a>, then return
"<code>ipv6</code>".

<li><p>Assert: <a>this</a>'s <a for=URLHost>host</a> is a <a>domain</a>.

<li><p>Return "<code>domain</code>".
</ol>

<p>The <dfn for=URLHost>stringification behavior</dfn> and
<dfn method for=URLHost><code>toJSON()</code></dfn> method steps, are to return <a>this</a>'s
<a for=URLHost>host</a>, <a lt="host serializer">serialized</a>.



<h2 id=acknowledgments class=no-num>Acknowledgments</h2>

Expand Down Expand Up @@ -3614,7 +3662,8 @@ Wei Wang,
Wolf Lammen,
山岸和利 (Yamagishi Kazutoshi),
Yongsheng Zhang,
成瀬ゆい (Yui Naruse), and
成瀬ゆい (Yui Naruse),
Zach Lym, and
zealousidealroll
for being awesome!

Expand Down

0 comments on commit 7f77861

Please sign in to comment.