Re: [whatwg/url] Expose a URLHost class to JavaScript (#288)

TimothyGu commented on this pull request.



> +invoked, must run these steps:
+
+<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 method for=URLHost><code>unicode()</code></dfn> method, when invoked, must run these
+steps:
+
+<ol>
+ <li><p>If <a>context object</a>'s <a for=URLHost>host</a> is not a <a>domain</a>, then <a>throw</a>
+ a {{TypeError}}.

Is throwing an error here really necessary? Having to write

```js
let hostStr;
if (host.type === "domain")
  hostStr = host.unicode();
hostStr = host.toString();
```

everywhere sounds inconvenient.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/pull/288#pullrequestreview-30266195

Received on Friday, 31 March 2017 14:53:39 UTC