Skip to content

Commit 2ff107d

Browse files
lovelljasnell
authored andcommitted
test: add case for url.parse throwing a URIError
The auth property of a URL is decoded via decodeURIComponent, which can throw a URIError. The test URL here will trigger this. Adds documentation on the possible errors url.parse can throw. PR-URL: #12135 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent eefdf45 commit 2ff107d

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

doc/api/url.md

+4
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ added: v0.1.25
259259
The `url.parse()` method takes a URL string, parses it, and returns a URL
260260
object.
261261

262+
A `TypeError` is thrown if `urlString` is not a string.
263+
264+
A `URIError` is thrown if the `auth` property is present but cannot be decoded.
265+
262266
## url.resolve(from, to)
263267
<!-- YAML
264268
added: v0.1.25

test/parallel/test-url-parse-invalid-input.js

+2
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ const url = require('url');
1616
].forEach(function(val) {
1717
assert.throws(function() { url.parse(val); }, TypeError);
1818
});
19+
20+
assert.throws(function() { url.parse('http://%E0%A4%A@fail'); }, /^URIError: URI malformed$/);

0 commit comments

Comments
 (0)