File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
packages/angular_devkit/core/src/virtual-fs Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -298,9 +298,11 @@ export type PosixPath = string & {
298298} ;
299299
300300export function asWindowsPath ( path : Path ) : WindowsPath {
301- const drive = path . match ( / ^ \/ ( \w ) \/ ( .* ) $ / ) ;
301+ const drive = path . match ( / ^ \/ ( \w ) (?: \/ ( .* ) ) ? $ / ) ;
302302 if ( drive ) {
303- return `${ drive [ 1 ] } :\\${ drive [ 2 ] . replace ( / \/ / g, '\\' ) } ` as WindowsPath ;
303+ const subPath = drive [ 2 ] ? drive [ 2 ] . replace ( / \/ / g, '\\' ) : '' ;
304+
305+ return `${ drive [ 1 ] } :\\${ subPath } ` as WindowsPath ;
304306 }
305307
306308 return path . replace ( / \/ / g, '\\' ) as WindowsPath ;
Original file line number Diff line number Diff line change 88import {
99 InvalidPathException ,
1010 Path ,
11+ asWindowsPath ,
1112 basename ,
1213 dirname ,
1314 join ,
@@ -159,4 +160,11 @@ describe('path', () => {
159160 expect ( basename ( normalize ( '.' ) ) ) . toBe ( '' ) ;
160161 expect ( basename ( normalize ( './a/b/c' ) ) ) . toBe ( 'c' ) ;
161162 } ) ;
163+
164+ it ( 'asWindowsPath' , ( ) => {
165+ expect ( asWindowsPath ( normalize ( 'c:/' ) ) ) . toBe ( 'c:\\' ) ;
166+ expect ( asWindowsPath ( normalize ( 'c:/b/' ) ) ) . toBe ( 'c:\\b' ) ;
167+ expect ( asWindowsPath ( normalize ( 'c:/b/c' ) ) ) . toBe ( 'c:\\b\\c' ) ;
168+ } ) ;
169+
162170} ) ;
You can’t perform that action at this time.
0 commit comments