@@ -1414,20 +1414,20 @@ const backslashRegEx = /\\/g;
1414
1414
const newlineRegEx = / \n / g;
1415
1415
const carriageReturnRegEx = / \r / g;
1416
1416
const tabRegEx = / \t / g;
1417
- const questionRegex = / \? / ;
1418
- const hashRegex = / # / ;
1417
+ const questionRegex = / \? / g ;
1418
+ const hashRegex = / # / g ;
1419
1419
1420
1420
function encodePathChars ( filepath ) {
1421
- if ( StringPrototypeIncludes ( filepath , '%' ) )
1421
+ if ( StringPrototypeIndexOf ( filepath , '%' ) !== - 1 )
1422
1422
filepath = RegExpPrototypeSymbolReplace ( percentRegEx , filepath , '%25' ) ;
1423
1423
// In posix, backslash is a valid character in paths:
1424
- if ( ! isWindows && StringPrototypeIncludes ( filepath , '\\' ) )
1424
+ if ( ! isWindows && StringPrototypeIndexOf ( filepath , '\\' ) !== - 1 )
1425
1425
filepath = RegExpPrototypeSymbolReplace ( backslashRegEx , filepath , '%5C' ) ;
1426
- if ( StringPrototypeIncludes ( filepath , '\n' ) )
1426
+ if ( StringPrototypeIndexOf ( filepath , '\n' ) !== - 1 )
1427
1427
filepath = RegExpPrototypeSymbolReplace ( newlineRegEx , filepath , '%0A' ) ;
1428
- if ( StringPrototypeIncludes ( filepath , '\r' ) )
1428
+ if ( StringPrototypeIndexOf ( filepath , '\r' ) !== - 1 )
1429
1429
filepath = RegExpPrototypeSymbolReplace ( carriageReturnRegEx , filepath , '%0D' ) ;
1430
- if ( StringPrototypeIncludes ( filepath , '\t' ) )
1430
+ if ( StringPrototypeIndexOf ( filepath , '\t' ) !== - 1 )
1431
1431
filepath = RegExpPrototypeSymbolReplace ( tabRegEx , filepath , '%09' ) ;
1432
1432
return filepath ;
1433
1433
}
@@ -1473,9 +1473,9 @@ function pathToFileURL(filepath) {
1473
1473
// Therefore, encoding is required to eliminate parsing them in different states.
1474
1474
// This is done as an optimization to not creating a URL instance and
1475
1475
// later triggering pathname setter, which impacts performance
1476
- if ( StringPrototypeIncludes ( resolved , '?' ) )
1476
+ if ( StringPrototypeIndexOf ( resolved , '?' ) !== - 1 )
1477
1477
resolved = RegExpPrototypeSymbolReplace ( questionRegex , resolved , '%3F' ) ;
1478
- if ( StringPrototypeIncludes ( resolved , '#' ) )
1478
+ if ( StringPrototypeIndexOf ( resolved , '#' ) !== - 1 )
1479
1479
resolved = RegExpPrototypeSymbolReplace ( hashRegex , resolved , '%23' ) ;
1480
1480
return new URL ( `file://${ resolved } ` ) ;
1481
1481
}
0 commit comments