node/test/parallel/test-url-parse-invalid-input.js
Andrei Cioromila 7906ed50fa test: add regex check in test-url-parse-invalid-input
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>
2017-05-16 12:10:37 +02:00

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$/);