mirror of
https://github.com/nodejs/node.git
synced 2025-05-07 06:31:11 +00:00

Use a regex to validate the error message. PR-URL: https://github.com/nodejs/node/pull/12879 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: David Cai <davidcai1993@yahoo.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
25 lines
530 B
JavaScript
25 lines
530 B
JavaScript
'use strict';
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const url = require('url');
|
|
|
|
// https://github.com/joyent/node/issues/568
|
|
[
|
|
undefined,
|
|
null,
|
|
true,
|
|
false,
|
|
0.0,
|
|
0,
|
|
[],
|
|
{},
|
|
() => {},
|
|
Symbol('foo')
|
|
].forEach((val) => {
|
|
assert.throws(() => { url.parse(val); },
|
|
/^TypeError: Parameter "url" must be a string, not (undefined|boolean|number|object|function|symbol)$/);
|
|
});
|
|
|
|
assert.throws(() => { url.parse('http://%E0%A4%A@fail'); },
|
|
/^URIError: URI malformed$/);
|