@@ -17,9 +17,13 @@ suite("Uri sanity checks", () => {
17
17
} ) ;
18
18
19
19
test ( "Uri.file() with Windows path with backslash" , ( ) => {
20
- // Observation: Normalizes drive letter and slashes
20
+ // Observation: Normalizes drive letter and slashes on Windows, not other OS
21
21
let uri = vscode . Uri . file ( "C:\\test\\file.txt" )
22
- assert . equal ( "file:///c:/test/file.txt" , uri . toString ( true ) ) ;
22
+ if ( process . platform === "win32" ) {
23
+ assert . equal ( "file:///c:/test/file.txt" , uri . toString ( true ) ) ;
24
+ } else {
25
+ assert . equal ( "file:///c:\\test\\file.txt" , uri . toString ( true ) ) ;
26
+ }
23
27
} ) ;
24
28
25
29
test ( "Uri.file() with Windows path with frontslash" , ( ) => {
@@ -41,13 +45,16 @@ suite("Uri sanity checks", () => {
41
45
} ) ;
42
46
43
47
test ( "Uri.parse() with incorrect two-slash Windows path" , ( ) => {
44
- // Observation: "C:" becomes the authority, fsPath resolves UNC-path to "C:" host
48
+ // Observation: "C:" becomes the authority, fsPath resolves UNC-path to "C:" host on Windows
45
49
let uri = vscode . Uri . parse ( "file://C:/test/dir/file.txt" )
46
50
assert . equal ( "C:" , uri . authority ) ;
47
51
assert . equal ( "/test/dir/file.txt" , uri . path , "path" ) ;
48
52
49
- // TODO; Backslashes here are prob windows-only
50
- assert . equal ( "\\\\C:\\test\\dir\\file.txt" , uri . fsPath , "fsPath" ) ;
53
+ if ( process . platform === "win32" ) {
54
+ assert . equal ( "\\\\C:\\test\\dir\\file.txt" , uri . fsPath , "fsPath" ) ;
55
+ } else {
56
+ assert . equal ( "//C:/test/dir/file.txt" , uri . fsPath , "fsPath" ) ;
57
+ }
51
58
52
59
assert . equal ( "file://c:/test/dir/file.txt" , uri . toString ( true ) ) ;
53
60
} )
@@ -58,8 +65,11 @@ suite("Uri sanity checks", () => {
58
65
assert . equal ( "" , uri . authority , "authority" ) ;
59
66
assert . equal ( "/C:/test/dir/file.txt" , uri . path , "path" ) ;
60
67
61
- // TODO; Backslashes here are prob windows-only
62
- assert . equal ( "c:\\test\\dir\\file.txt" , uri . fsPath , "fsPath" ) ;
68
+ if ( process . platform === "win32" ) {
69
+ assert . equal ( "c:\\test\\dir\\file.txt" , uri . fsPath , "fsPath" ) ;
70
+ } else {
71
+ assert . equal ( "c:/test/dir/file.txt" , uri . fsPath , "fsPath" ) ;
72
+ }
63
73
64
74
assert . equal ( "file:///c:/test/dir/file.txt" , uri . toString ( true ) ) ;
65
75
} )
@@ -70,8 +80,11 @@ suite("Uri sanity checks", () => {
70
80
assert . equal ( "" , uri . authority , "authority" ) ;
71
81
assert . equal ( "/dir/file.txt" , uri . path , "path" ) ;
72
82
73
- // TODO; Backslashes here are prob windows-only
74
- assert . equal ( "\\dir\\file.txt" , uri . fsPath , "fsPath" ) ;
83
+ if ( process . platform === "win32" ) {
84
+ assert . equal ( "\\dir\\file.txt" , uri . fsPath , "fsPath" ) ;
85
+ } else {
86
+ assert . equal ( "/dir/file.txt" , uri . fsPath , "fsPath" ) ;
87
+ }
75
88
76
89
assert . equal ( "file:///dir/file.txt" , uri . toString ( true ) ) ;
77
90
} ) ;
0 commit comments