Skip to content
Permalink
Browse files

url: error when domainTo*() is called w/o argument

PR-URL: #12134
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information...
TimothyGu authored and jasnell committed Mar 20, 2017
1 parent f6ddbaf commit c4469c49ecc2d6624466466e6b496c31d0e9fbed
Showing with 15 additions and 0 deletions.
  1. +6 −0 lib/internal/url.js
  2. +9 −0 test/parallel/test-whatwg-url-domainto.js
@@ -1308,11 +1308,17 @@ function originFor(url, base) {
}

function domainToASCII(domain) {
if (arguments.length < 1)
throw new TypeError('"domain" argument must be specified');

// toUSVString is not needed.
return binding.domainToASCII(`${domain}`);
}

function domainToUnicode(domain) {
if (arguments.length < 1)
throw new TypeError('"domain" argument must be specified');

// toUSVString is not needed.
return binding.domainToUnicode(`${domain}`);
}
@@ -12,6 +12,15 @@ const { domainToASCII, domainToUnicode } = require('url');
// Tests below are not from WPT.
const tests = require('../fixtures/url-idna.js');

{
assert.throws(() => domainToASCII(),
/^TypeError: "domain" argument must be specified$/);
assert.throws(() => domainToUnicode(),
/^TypeError: "domain" argument must be specified$/);
assert.strictEqual(domainToASCII(undefined), 'undefined');
assert.strictEqual(domainToUnicode(undefined), 'undefined');
}

{
for (const [i, { ascii, unicode }] of tests.valid.entries()) {
assert.strictEqual(ascii, domainToASCII(unicode),

0 comments on commit c4469c4

Please sign in to comment.
You can’t perform that action at this time.