@@ -360,9 +360,7 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
360360 // First, make 100% sure that any "autoEscape" chars get
361361 // escaped, even if encodeURIComponent doesn't think they
362362 // need to be.
363- const result = autoEscapeStr ( rest ) ;
364- if ( result !== undefined )
365- rest = result ;
363+ rest = autoEscapeStr ( rest ) ;
366364 }
367365
368366 var questionIdx = - 1 ;
@@ -443,8 +441,7 @@ function validateHostname(self, rest, hostname) {
443441
444442// Automatically escape all delimiters and unwise characters from RFC 2396.
445443// Also escape single quotes in case of an XSS attack.
446- // Return undefined if the string doesn't need escaping,
447- // otherwise return the escaped string.
444+ // Return the escaped string.
448445function autoEscapeStr ( rest ) {
449446 var escaped = '' ;
450447 var lastEscapedPos = 0 ;
@@ -539,13 +536,11 @@ function autoEscapeStr(rest) {
539536 break ;
540537 }
541538 }
542- if ( lastEscapedPos === 0 ) // Nothing has been escaped.
543- return ;
544539 // There are ordinary characters at the end.
545540 if ( lastEscapedPos < rest . length )
546- return escaped + rest . slice ( lastEscapedPos ) ;
547- else // The last character is escaped.
548- return escaped ;
541+ escaped += rest . slice ( lastEscapedPos ) ;
542+
543+ return escaped ;
549544}
550545
551546// format a parsed object into a url string
0 commit comments