@@ -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.
446443function 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