@@ -285,10 +285,16 @@ const win32 = {
285285 j ++ ;
286286 }
287287 if ( j === len || j !== last ) {
288- // We matched a UNC root
289- device =
290- `\\\\${ firstPart } \\${ StringPrototypeSlice ( path , last , j ) } ` ;
291- rootEnd = j ;
288+ if ( firstPart !== '.' && firstPart !== '?' ) {
289+ // We matched a UNC root
290+ device =
291+ `\\\\${ firstPart } \\${ StringPrototypeSlice ( path , last , j ) } ` ;
292+ rootEnd = j ;
293+ } else {
294+ // We matched a device root (e.g. \\\\.\\PHYSICALDRIVE0)
295+ device = `\\\\${ firstPart } ` ;
296+ rootEnd = 4 ;
297+ }
292298 }
293299 }
294300 }
@@ -398,17 +404,22 @@ const win32 = {
398404 ! isPathSeparator ( StringPrototypeCharCodeAt ( path , j ) ) ) {
399405 j ++ ;
400406 }
401- if ( j === len ) {
402- // We matched a UNC root only
403- // Return the normalized version of the UNC root since there
404- // is nothing left to process
405- return `\\\\${ firstPart } \\${ StringPrototypeSlice ( path , last ) } \\` ;
406- }
407- if ( j !== last ) {
408- // We matched a UNC root with leftovers
409- device =
410- `\\\\${ firstPart } \\${ StringPrototypeSlice ( path , last , j ) } ` ;
411- rootEnd = j ;
407+ if ( j === len || j !== last ) {
408+ if ( firstPart === '.' || firstPart === '?' ) {
409+ // We matched a device root (e.g. \\\\.\\PHYSICALDRIVE0)
410+ device = `\\\\${ firstPart } ` ;
411+ rootEnd = 4 ;
412+ } else if ( j === len ) {
413+ // We matched a UNC root only
414+ // Return the normalized version of the UNC root since there
415+ // is nothing left to process
416+ return `\\\\${ firstPart } \\${ StringPrototypeSlice ( path , last ) } \\` ;
417+ } else {
418+ // We matched a UNC root with leftovers
419+ device =
420+ `\\\\${ firstPart } \\${ StringPrototypeSlice ( path , last , j ) } ` ;
421+ rootEnd = j ;
422+ }
412423 }
413424 }
414425 }
0 commit comments