Skip to content

Commit 533d5c8

Browse files
committed
Expose a URLHost class to JavaScript
Also export host parser (already in use by HTML). Fixes #274.
1 parent 6a9f7ea commit 533d5c8

File tree

1 file changed

+62
-2
lines changed

1 file changed

+62
-2
lines changed

url.bs

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3208,6 +3208,65 @@ e.g., "newURL" and "oldURL".
32083208
naming. [[!HTML]]
32093209

32103210

3211+
<h3 id=urlhost-class>URLHost class</h3>
3212+
3213+
<pre class=idl>
3214+
[Constructor(USVString host),
3215+
Exposed=(Window,Worker)]
3216+
interface URLHost {
3217+
USVString unicode();
3218+
readonly attribute URLHostType type;
3219+
3220+
stringifier USVString toJSON();
3221+
};
3222+
3223+
enum URLHostType { "ipv4", "ipv6", "domain" };</pre>
3224+
3225+
<p>Each {{URLHost}} object has an associated <dfn for=URLHost>host</dfn> (a <a for=/>host</a>).
3226+
3227+
<hr>
3228+
3229+
<p>The <dfn constructor for=URLHost><code>URLHost(<var>input</var>)</code></dfn> constructor, when
3230+
invoked, must run these steps:
3231+
3232+
<ol>
3233+
<li><p>Let <var>host</var> be the result of <a>host parsing</a> <var>input</var> with true.
3234+
3235+
<li><p>If <var>host</var> is failure, then <a>throw</a> a {{TypeError}}.
3236+
3237+
<li><p>Return a new {{URLHost}} object whose <a for=URLHost>host</a> is <var>host</var>.
3238+
</ol>
3239+
3240+
<p>The <dfn method for=URLHost><code>unicode()</code></dfn> method, when invoked, must run these
3241+
steps:
3242+
3243+
<ol>
3244+
<li><p>If <a>context object</a>'s <a for=URLHost>host</a> is not a <a>domain</a>, then <a>throw</a>
3245+
a {{TypeError}}.
3246+
3247+
<li><p>Let <var>unicodeDomain</var> be the result of running <a>domain to Unicode</a> on
3248+
<a>context object</a>'s <a for=URLHost>host</a>.
3249+
3250+
<li><p>Return <var>unicodeDomain</var>, <a lt="host serializer">serialized</a>.
3251+
</ol>
3252+
3253+
<p>The <dfn attribute for=URLHost><code>type</code></dfn> attribute's getter, must run these steps:
3254+
3255+
<ol>
3256+
<li><p>If <a>context object</a>'s <a for=URLHost>host</a> is an <a>IPv4 address</a>, then return
3257+
"<code>ipv4</code>".
3258+
3259+
<li><p>If <a>context object</a>'s <a for=URLHost>host</a> is an <a>IPv6 address</a>, then return
3260+
"<code>ipv6</code>".
3261+
3262+
<li><p>Return "<code>domain</code>".
3263+
</ol>
3264+
3265+
<p>The <dfn for=URLHost>stringification behavior</dfn> and
3266+
<dfn method for=URLHost><code>toJSON()</code></dfn> method, when invoked, must return
3267+
<a>context object</a>'s <a for=URLHost>host</a>, <a lt="host serializer">serialized</a>.
3268+
3269+
32113270

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

@@ -3302,8 +3361,9 @@ Trevor Rowbotham,
33023361
Valentin Gosu,
33033362
Vyacheslav Matva,
33043363
Wei Wang,
3305-
山岸和利 (Yamagishi Kazutoshi), and
3306-
成瀬ゆい (Yui Naruse)
3364+
山岸和利 (Yamagishi Kazutoshi),
3365+
成瀬ゆい (Yui Naruse), and
3366+
Zach Lym
33073367
for being awesome!
33083368

33093369
<p>This standard is written by

0 commit comments

Comments
 (0)