@@ -268,10 +268,16 @@ const win32 = {
268268 j ++ ;
269269 }
270270 if ( j === len || j !== last ) {
271- // We matched a UNC root
272- device =
273- `\\\\${ firstPart } \\${ StringPrototypeSlice ( path , last , j ) } ` ;
274- rootEnd = j ;
271+ if ( firstPart !== '.' && firstPart !== '?' ) {
272+ // We matched a UNC root
273+ device =
274+ `\\\\${ firstPart } \\${ StringPrototypeSlice ( path , last , j ) } ` ;
275+ rootEnd = j ;
276+ } else {
277+ // We matched a device root (e.g. \\\\.\\PHYSICALDRIVE0)
278+ device = `\\\\${ firstPart } ` ;
279+ rootEnd = 4 ;
280+ }
275281 }
276282 }
277283 }
@@ -381,17 +387,22 @@ const win32 = {
381387 ! isPathSeparator ( StringPrototypeCharCodeAt ( path , j ) ) ) {
382388 j ++ ;
383389 }
384- if ( j === len ) {
385- // We matched a UNC root only
386- // Return the normalized version of the UNC root since there
387- // is nothing left to process
388- return `\\\\${ firstPart } \\${ StringPrototypeSlice ( path , last ) } \\` ;
389- }
390- if ( j !== last ) {
391- // We matched a UNC root with leftovers
392- device =
393- `\\\\${ firstPart } \\${ StringPrototypeSlice ( path , last , j ) } ` ;
394- rootEnd = j ;
390+ if ( j === len || j !== last ) {
391+ if ( firstPart === '.' || firstPart === '?' ) {
392+ // We matched a device root (e.g. \\\\.\\PHYSICALDRIVE0)
393+ device = `\\\\${ firstPart } ` ;
394+ rootEnd = 4 ;
395+ } else if ( j === len ) {
396+ // We matched a UNC root only
397+ // Return the normalized version of the UNC root since there
398+ // is nothing left to process
399+ return `\\\\${ firstPart } \\${ StringPrototypeSlice ( path , last ) } \\` ;
400+ } else {
401+ // We matched a UNC root with leftovers
402+ device =
403+ `\\\\${ firstPart } \\${ StringPrototypeSlice ( path , last , j ) } ` ;
404+ rootEnd = j ;
405+ }
395406 }
396407 }
397408 }
0 commit comments