@@ -14,20 +14,41 @@ describe('filePathToUri', () => {
14
14
expect ( uri ) . toMatch ( / ^ f i l e / ) ;
15
15
} ) ;
16
16
17
- it ( 'should handle windows path' , ( ) => {
18
- const uri = filePathToUri ( 'C:\\ project\\ main.ts' ) ;
19
- expect ( uri ) . toBe ( 'file:///c%3A%5Cproject%5Cmain .ts' ) ;
17
+ it ( 'should handle network path' , ( ) => {
18
+ const uri = filePathToUri ( '// project/ main.ts' ) ;
19
+ expect ( uri ) . toBe ( 'file://project/main .ts' ) ;
20
20
} ) ;
21
+
22
+ if ( process . platform === 'win32' ) {
23
+ it ( 'should handle windows path' , ( ) => {
24
+ const uri = filePathToUri ( 'C:\\project\\main.ts' ) ;
25
+ expect ( uri ) . toBe ( 'file:///c%3A/project/main.ts' ) ;
26
+ } ) ;
27
+ }
21
28
} ) ;
22
29
23
30
describe ( 'uriToFilePath' , ( ) => {
24
- it ( 'should return valid fsPath for unix' , ( ) => {
25
- const filePath = uriToFilePath ( 'file:///project/main.ts' ) ;
26
- expect ( filePath ) . toBe ( '/project/main.ts' ) ;
27
- } ) ;
31
+ if ( process . platform === 'win32' ) {
32
+ it ( 'should return valid fsPath for windows' , ( ) => {
33
+ const filePath = uriToFilePath ( 'file:///c%3A/project/main.ts' ) ;
34
+ expect ( filePath ) . toBe ( 'c:\\project\\main.ts' ) ;
35
+ } ) ;
28
36
29
- it ( 'should return valid fsPath for windows' , ( ) => {
30
- const filePath = uriToFilePath ( 'file:///c%3A%5Cproject%5Cmain.ts' ) ;
31
- expect ( filePath ) . toBe ( 'c:\\project\\main.ts' ) ;
32
- } ) ;
37
+ it ( 'should return valid fsPath for network file uri' , ( ) => {
38
+ const filePath = uriToFilePath ( 'file://project/main.ts' ) ;
39
+ expect ( filePath ) . toBe ( '\\\\project\\main.ts' ) ;
40
+ } ) ;
41
+ }
42
+
43
+ if ( process . platform !== 'win32' ) {
44
+ it ( 'should return valid fsPath for unix' , ( ) => {
45
+ const filePath = uriToFilePath ( 'file:///project/main.ts' ) ;
46
+ expect ( filePath ) . toBe ( '/project/main.ts' ) ;
47
+ } ) ;
48
+
49
+ it ( 'should return valid fsPath for network file uri' , ( ) => {
50
+ const filePath = uriToFilePath ( 'file://project/main.ts' ) ;
51
+ expect ( filePath ) . toBe ( '//project/main.ts' ) ;
52
+ } ) ;
53
+ }
33
54
} ) ;
0 commit comments