@@ -360,9 +360,7 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
360
360
// First, make 100% sure that any "autoEscape" chars get
361
361
// escaped, even if encodeURIComponent doesn't think they
362
362
// need to be.
363
- const result = autoEscapeStr ( rest ) ;
364
- if ( result !== undefined )
365
- rest = result ;
363
+ rest = autoEscapeStr ( rest ) ;
366
364
}
367
365
368
366
var questionIdx = - 1 ;
@@ -443,8 +441,7 @@ function validateHostname(self, rest, hostname) {
443
441
444
442
// Automatically escape all delimiters and unwise characters from RFC 2396.
445
443
// 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.
448
445
function autoEscapeStr ( rest ) {
449
446
var escaped = '' ;
450
447
var lastEscapedPos = 0 ;
@@ -540,12 +537,13 @@ function autoEscapeStr(rest) {
540
537
}
541
538
}
542
539
if ( lastEscapedPos === 0 ) // Nothing has been escaped.
543
- return ;
540
+ return rest ;
541
+
544
542
// There are ordinary characters at the end.
545
543
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 ;
549
547
}
550
548
551
549
// format a parsed object into a url string
0 commit comments