@@ -229,7 +229,98 @@ func TestParseURI_WSHLocalShorthand(t *testing.T) {
229
229
if c .GetFullURI () != expected {
230
230
t .Fatalf ("expected full URI to be %q, got %q" , expected , c .GetFullURI ())
231
231
}
232
+ }
233
+
234
+ func TestParseURI_WSHWSL (t * testing.T ) {
235
+ t .Parallel ()
236
+ cstr := "wsh://wsl://Ubuntu/path/to/file"
237
+
238
+ testUri := func () {
239
+ c , err := connparse .ParseURI (cstr )
240
+ if err != nil {
241
+ t .Fatalf ("failed to parse URI: %v" , err )
242
+ }
243
+ expected := "/path/to/file"
244
+ if c .Path != expected {
245
+ t .Fatalf ("expected path to be %q, got %q" , expected , c .Path )
246
+ }
247
+ expected = "wsl://Ubuntu"
248
+ if c .Host != expected {
249
+ t .Fatalf ("expected host to be %q, got %q" , expected , c .Host )
250
+ }
251
+ expected = "wsh"
252
+ if c .Scheme != expected {
253
+ t .Fatalf ("expected scheme to be %q, got %q" , expected , c .Scheme )
254
+ }
255
+ expected = "wsh://wsl://Ubuntu/path/to/file"
256
+ if expected != c .GetFullURI () {
257
+ t .Fatalf ("expected full URI to be %q, got %q" , expected , c .GetFullURI ())
258
+ }
259
+ }
260
+ t .Log ("Testing with scheme" )
261
+ testUri ()
262
+
263
+ t .Log ("Testing without scheme" )
264
+ cstr = "//wsl://Ubuntu/path/to/file"
265
+ testUri ()
266
+ }
267
+
268
+ func TestParseUri_LocalWindowsAbsPath (t * testing.T ) {
269
+ t .Parallel ()
270
+ cstr := "wsh://local/C:\\ path\\ to\\ file"
232
271
272
+ testAbsPath := func () {
273
+ c , err := connparse .ParseURI (cstr )
274
+ if err != nil {
275
+ t .Fatalf ("failed to parse URI: %v" , err )
276
+ }
277
+ expected := "C:\\ path\\ to\\ file"
278
+ if c .Path != expected {
279
+ t .Fatalf ("expected path to be %q, got %q" , expected , c .Path )
280
+ }
281
+ expected = "local"
282
+ if c .Host != expected {
283
+ t .Fatalf ("expected host to be %q, got %q" , expected , c .Host )
284
+ }
285
+ expected = "wsh"
286
+ if c .Scheme != expected {
287
+ t .Fatalf ("expected scheme to be %q, got %q" , expected , c .Scheme )
288
+ }
289
+ expected = "wsh://local/C:\\ path\\ to\\ file"
290
+ if c .GetFullURI () != expected {
291
+ t .Fatalf ("expected full URI to be %q, got %q" , expected , c .GetFullURI ())
292
+ }
293
+ }
294
+
295
+ t .Log ("Testing with scheme" )
296
+ testAbsPath ()
297
+ t .Log ("Testing without scheme" )
298
+ cstr = "//local/C:\\ path\\ to\\ file"
299
+ testAbsPath ()
300
+ }
301
+
302
+ func TestParseURI_LocalWindowsRelativeShorthand (t * testing.T ) {
303
+ cstr := "/~\\ path\\ to\\ file"
304
+ c , err := connparse .ParseURI (cstr )
305
+ if err != nil {
306
+ t .Fatalf ("failed to parse URI: %v" , err )
307
+ }
308
+ expected := "~\\ path\\ to\\ file"
309
+ if c .Path != expected {
310
+ t .Fatalf ("expected path to be %q, got %q" , expected , c .Path )
311
+ }
312
+ expected = "local"
313
+ if c .Host != expected {
314
+ t .Fatalf ("expected host to be %q, got %q" , expected , c .Host )
315
+ }
316
+ expected = "wsh"
317
+ if c .Scheme != expected {
318
+ t .Fatalf ("expected scheme to be %q, got %q" , expected , c .Scheme )
319
+ }
320
+ expected = "wsh://local/~\\ path\\ to\\ file"
321
+ if c .GetFullURI () != expected {
322
+ t .Fatalf ("expected full URI to be %q, got %q" , expected , c .GetFullURI ())
323
+ }
233
324
}
234
325
235
326
func TestParseURI_BasicS3 (t * testing.T ) {
@@ -239,7 +330,7 @@ func TestParseURI_BasicS3(t *testing.T) {
239
330
if err != nil {
240
331
t .Fatalf ("failed to parse URI: %v" , err )
241
332
}
242
- expected := "/ path/to/file"
333
+ expected := "path/to/file"
243
334
if c .Path != expected {
244
335
t .Fatalf ("expected path to be %q, got %q" , expected , c .Path )
245
336
}
0 commit comments