@@ -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 ;
@@ -540,12 +537,13 @@ function autoEscapeStr(rest) {
540537 }
541538 }
542539 if ( lastEscapedPos === 0 ) // Nothing has been escaped.
543- return ;
540+ return rest ;
541+
544542 // There are ordinary characters at the end.
545543 if ( lastEscapedPos < rest . length )
546- return escaped + rest . slice ( lastEscapedPos ) ;
547- else // The last character is escaped.
548- return escaped ;
544+ escaped += rest . slice ( lastEscapedPos ) ;
545+
546+ return escaped ;
549547}
550548
551549// format a parsed object into a url string
0 commit comments