Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions test/parallel/test-url-parse-invalid-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ const url = require('url');
0.0,
0,
[],
{}
].forEach(function(val) {
assert.throws(function() { url.parse(val); }, TypeError);
{},
() => {},
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(function() { url.parse('http://%E0%A4%A@fail'); }, /^URIError: URI malformed$/);
assert.throws(() => { url.parse('http://%E0%A4%A@fail'); },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very minor nit: the { and } around the body of the arrow function here can be omitted but isn't necessary.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say the braces should not be omitted. That would change it from merely running url.parse() to returning a value. If it was { return url.parse(...); } then omitting the braces (and the return) would make sense. It's mostly a semantic difference, but I think it's important.

/^URIError: URI malformed$/);