@@ -59,10 +59,14 @@ export default class Path {
5959 if ( ! input . startsWith ( "/" ) && ! input . startsWith ( "\\" ) ) {
6060 throw new Error ( `invalid absolute path: ${ input } ` )
6161 }
62- //TODO shouldn’t be C: necessarily
63- // should it be based on PWD or system default drive?
64- // NOTE also: maybe we shouldn't do this anyway?
65- input = `C:\\${ input } `
62+ if ( ! input . startsWith ( '\\\\' ) ) {
63+ // ^^ \\network\drive is valid path notation on windows
64+
65+ //TODO shouldn’t be C: necessarily
66+ // should it be based on PWD or system default drive?
67+ // NOTE also: maybe we shouldn't do this anyway?
68+ input = `C:\\${ input } `
69+ }
6670 }
6771 input = input . replace ( / \/ / g, '\\' )
6872 } else if ( input [ 0 ] != '/' ) {
@@ -72,10 +76,10 @@ export default class Path {
7276 this . string = normalize ( input )
7377
7478 function normalize ( path : string ) : string {
75- const segments = path . split ( SEP ) ;
76- const result = [ ] ;
79+ const segments = path . split ( SEP )
80+ const result = [ ]
7781
78- const start = Deno . build . os == 'windows' ? ( segments . shift ( ) ?? 'C: ') + '\\' : '/'
82+ const start = Deno . build . os == 'windows' ? ( segments . shift ( ) || '\\ ') + '\\' : '/'
7983
8084 for ( const segment of segments ) {
8185 if ( segment === '..' ) {
@@ -151,7 +155,7 @@ export default class Path {
151155 return this
152156 }
153157 function isAbsolute ( part : string ) {
154- if ( Deno . build . os == 'windows' && part ?. match ( / ^ [ a - z A - Z ] : / ) ) {
158+ if ( Deno . build . os == 'windows' && ( part ?. match ( / ^ [ a - z A - Z ] : / ) || part ?. startsWith ( "\\\\" ) ) ) {
155159 return true
156160 } else {
157161 return part . startsWith ( '/' )
0 commit comments