@@ -291,10 +291,16 @@ const win32 = {
291291 j ++ ;
292292 }
293293 if ( j === len || j !== last ) {
294- // We matched a UNC root
295- device =
296- `\\\\${ firstPart } \\${ StringPrototypeSlice ( path , last , j ) } ` ;
297- rootEnd = j ;
294+ if ( firstPart !== '.' && firstPart !== '?' ) {
295+ // We matched a UNC root
296+ device =
297+ `\\\\${ firstPart } \\${ StringPrototypeSlice ( path , last , j ) } ` ;
298+ rootEnd = j ;
299+ } else {
300+ // We matched a device root (e.g. \\\\.\\PHYSICALDRIVE0)
301+ device = `\\\\${ firstPart } ` ;
302+ rootEnd = 4 ;
303+ }
298304 }
299305 }
300306 }
@@ -404,17 +410,22 @@ const win32 = {
404410 ! isPathSeparator ( StringPrototypeCharCodeAt ( path , j ) ) ) {
405411 j ++ ;
406412 }
407- if ( j === len ) {
408- // We matched a UNC root only
409- // Return the normalized version of the UNC root since there
410- // is nothing left to process
411- return `\\\\${ firstPart } \\${ StringPrototypeSlice ( path , last ) } \\` ;
412- }
413- if ( j !== last ) {
414- // We matched a UNC root with leftovers
415- device =
416- `\\\\${ firstPart } \\${ StringPrototypeSlice ( path , last , j ) } ` ;
417- rootEnd = j ;
413+ if ( j === len || j !== last ) {
414+ if ( firstPart === '.' || firstPart === '?' ) {
415+ // We matched a device root (e.g. \\\\.\\PHYSICALDRIVE0)
416+ device = `\\\\${ firstPart } ` ;
417+ rootEnd = 4 ;
418+ } else if ( j === len ) {
419+ // We matched a UNC root only
420+ // Return the normalized version of the UNC root since there
421+ // is nothing left to process
422+ return `\\\\${ firstPart } \\${ StringPrototypeSlice ( path , last ) } \\` ;
423+ } else {
424+ // We matched a UNC root with leftovers
425+ device =
426+ `\\\\${ firstPart } \\${ StringPrototypeSlice ( path , last , j ) } ` ;
427+ rootEnd = j ;
428+ }
418429 }
419430 }
420431 }
0 commit comments