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
425425
426426 // Step 3: If it's a "file://" URL, then format it consistently
427427 // or convert it to a local filesystem path
428- let isFileUrl = path . substring ( 0 , 7 ) . toLowerCase ( ) === "file://" ;
428+ let isFileUrl = path . toLowerCase ( ) . startsWith ( "file://" ) ;
429429 if ( isFileUrl ) {
430430 // 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 ( / ^ \/ / , "" ) ;
432432
433433 // insert a colon (":") after the drive letter on Windows
434434 if ( isWindows ( ) && path [ 1 ] === "/" ) {
435- path = path [ 0 ] + ":" + path . substring ( 1 ) ;
435+ path = ` ${ path [ 0 ] } : ${ path . substring ( 1 ) } ` ;
436436 }
437437
438438 if ( keepFileProtocol ) {
@@ -453,7 +453,7 @@ export function toFileSystemPath(path: string | undefined, keepFileProtocol?: bo
453453 path = path . replace ( forwardSlashPattern , "\\" ) ;
454454
455455 // Capitalize the drive letter
456- if ( path . substring ( 1 , 2 ) === " :\\" ) {
456+ if ( path . match ( / ^ [ a - z ] : \\ / i ) ) {
457457 path = path [ 0 ] . toUpperCase ( ) + path . substring ( 1 ) ;
458458 }
459459 }
You can’t perform that action at this time.
0 commit comments