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