diff --git a/lib/url.js b/lib/url.js index 18925973bd45e9..fa7a6157435656 100644 --- a/lib/url.js +++ b/lib/url.js @@ -116,7 +116,6 @@ const { CHAR_TAB, CHAR_CARRIAGE_RETURN, CHAR_LINE_FEED, - CHAR_FORM_FEED, CHAR_NO_BREAK_SPACE, CHAR_ZERO_WIDTH_NOBREAK_SPACE, CHAR_HASH, @@ -181,11 +180,7 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) { const code = url.charCodeAt(i); // Find first and last non-whitespace characters for trimming - const isWs = code === CHAR_SPACE || - code === CHAR_TAB || - code === CHAR_CARRIAGE_RETURN || - code === CHAR_LINE_FEED || - code === CHAR_FORM_FEED || + const isWs = code < 33 || code === CHAR_NO_BREAK_SPACE || code === CHAR_ZERO_WIDTH_NOBREAK_SPACE; if (start === -1) { diff --git a/test/parallel/test-url-parse-format.js b/test/parallel/test-url-parse-format.js index e1cf80a2778abd..99a6ace23a2fb3 100644 --- a/test/parallel/test-url-parse-format.js +++ b/test/parallel/test-url-parse-format.js @@ -977,6 +977,21 @@ const parseTests = { path: '/everybody', href: '//fhqwhgads@example.com/everybody#to-the-limit' }, + + '\bhttp://example.com/\b': { + protocol: 'http:', + slashes: true, + auth: null, + host: 'example.com', + port: null, + hostname: 'example.com', + hash: null, + search: null, + query: null, + pathname: '/', + path: '/', + href: 'http://example.com/' + } }; for (const u in parseTests) {