File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -425,14 +425,14 @@ export function toFileSystemPath(path: string | undefined, keepFileProtocol?: bo
425
425
426
426
// Step 3: If it's a "file://" URL, then format it consistently
427
427
// or convert it to a local filesystem path
428
- let isFileUrl = path . substring ( 0 , 7 ) . toLowerCase ( ) === "file://" ;
428
+ let isFileUrl = path . toLowerCase ( ) . startsWith ( "file://" ) ;
429
429
if ( isFileUrl ) {
430
430
// Strip-off the protocol, and the initial "/", if there is one
431
- path = path [ 7 ] === "/" ? path . substring ( 8 ) : path . substring ( 7 ) ;
431
+ path = path . replace ( / ^ f i l e : \/ \/ / , "" ) . replace ( / ^ \/ / , "" ) ;
432
432
433
433
// insert a colon (":") after the drive letter on Windows
434
434
if ( isWindows ( ) && path [ 1 ] === "/" ) {
435
- path = path [ 0 ] + ":" + path . substring ( 1 ) ;
435
+ path = ` ${ path [ 0 ] } : ${ path . substring ( 1 ) } ` ;
436
436
}
437
437
438
438
if ( keepFileProtocol ) {
@@ -453,7 +453,7 @@ export function toFileSystemPath(path: string | undefined, keepFileProtocol?: bo
453
453
path = path . replace ( forwardSlashPattern , "\\" ) ;
454
454
455
455
// Capitalize the drive letter
456
- if ( path . substring ( 1 , 2 ) === " :\\" ) {
456
+ if ( path . match ( / ^ [ a - z ] : \\ / i ) ) {
457
457
path = path [ 0 ] . toUpperCase ( ) + path . substring ( 1 ) ;
458
458
}
459
459
}
You can’t perform that action at this time.
0 commit comments