Skip to content

Commit a4fc432

Browse files
cyril-lakechMylesBorins
authored andcommitted
url: remove unused code from autoEscapeStr
PR-URL: #15086 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent b9e1f60 commit a4fc432

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

lib/url.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,7 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
358358
// First, make 100% sure that any "autoEscape" chars get
359359
// escaped, even if encodeURIComponent doesn't think they
360360
// need to be.
361-
const result = autoEscapeStr(rest);
362-
if (result !== undefined)
363-
rest = result;
361+
rest = autoEscapeStr(rest);
364362
}
365363

366364
var questionIdx = -1;
@@ -441,8 +439,7 @@ function validateHostname(self, rest, hostname) {
441439

442440
// Automatically escape all delimiters and unwise characters from RFC 2396.
443441
// Also escape single quotes in case of an XSS attack.
444-
// Return undefined if the string doesn't need escaping,
445-
// otherwise return the escaped string.
442+
// Return the escaped string.
446443
function autoEscapeStr(rest) {
447444
var escaped = '';
448445
var lastEscapedPos = 0;
@@ -538,12 +535,13 @@ function autoEscapeStr(rest) {
538535
}
539536
}
540537
if (lastEscapedPos === 0) // Nothing has been escaped.
541-
return;
538+
return rest;
539+
542540
// There are ordinary characters at the end.
543541
if (lastEscapedPos < rest.length)
544-
return escaped + rest.slice(lastEscapedPos);
545-
else // The last character is escaped.
546-
return escaped;
542+
escaped += rest.slice(lastEscapedPos);
543+
544+
return escaped;
547545
}
548546

549547
// format a parsed object into a url string

0 commit comments

Comments
 (0)