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

Expose a URLHost class to JavaScript #288

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
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>Set <a>this</a>'s <a for=URLHost>host</a> to <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