@@ -247,41 +247,88 @@ fn relative_unix_path() {
247
247
let test_url = "../project-name.git" ;
248
248
let parsed = GitUrl :: parse ( test_url) . expect ( "URL parse failed" ) ;
249
249
let expected = GitUrl {
250
- host : Some ( "host.tld" . to_string ( ) ) ,
250
+ host : None ,
251
251
name : "project-name" . to_string ( ) ,
252
- owner : Some ( "user" . to_string ( ) ) ,
252
+ owner : None ,
253
253
organization : None ,
254
- fullname : "../ project-name.git " . to_string ( ) ,
255
- scheme : Scheme :: Ftps ,
256
- user : Some ( "git" . to_string ( ) ) ,
254
+ fullname : "project-name" . to_string ( ) ,
255
+ scheme : Scheme :: File ,
256
+ user : None ,
257
257
token : None ,
258
258
port : None ,
259
259
path : "../project-name.git" . to_string ( ) ,
260
260
git_suffix : true ,
261
- scheme_prefix : true ,
261
+ scheme_prefix : false ,
262
+ } ;
263
+
264
+ assert_eq ! ( parsed, expected) ;
265
+ }
266
+
267
+ #[ test]
268
+ fn absolute_unix_path ( ) {
269
+ let test_url = "/path/to/project-name.git" ;
270
+ let parsed = GitUrl :: parse ( test_url) . expect ( "URL parse failed" ) ;
271
+ let expected = GitUrl {
272
+ host : None ,
273
+ name : "project-name" . to_string ( ) ,
274
+ owner : None ,
275
+ organization : None ,
276
+ fullname : "project-name" . to_string ( ) ,
277
+ scheme : Scheme :: File ,
278
+ user : None ,
279
+ token : None ,
280
+ port : None ,
281
+ path : "/path/to/project-name.git" . to_string ( ) ,
282
+ git_suffix : true ,
283
+ scheme_prefix : false ,
262
284
} ;
263
285
264
286
assert_eq ! ( parsed, expected) ;
265
287
}
266
288
289
+ // Issue #6 - Relative Windows paths will parse into Unix paths
267
290
#[ test]
268
291
fn relative_windows_path ( ) {
269
292
let test_url = "..\\ project-name.git" ;
270
293
let parsed = GitUrl :: parse ( test_url) . expect ( "URL parse failed" ) ;
271
294
let expected = GitUrl {
272
- host : Some ( "host.tld" . to_string ( ) ) ,
295
+ host : None ,
273
296
name : "project-name" . to_string ( ) ,
274
- owner : Some ( "user" . to_string ( ) ) ,
297
+ owner : None ,
275
298
organization : None ,
276
- fullname : "..\\ project-name.git" . to_string ( ) ,
277
- scheme : Scheme :: Ftps ,
278
- user : Some ( "git" . to_string ( ) ) ,
299
+ fullname : "project-name" . to_string ( ) ,
300
+ scheme : Scheme :: File ,
301
+ user : None ,
302
+ token : None ,
303
+ port : None ,
304
+ path : "../project-name.git" . to_string ( ) ,
305
+ git_suffix : true ,
306
+ scheme_prefix : false ,
307
+ } ;
308
+
309
+ assert_eq ! ( parsed, expected) ;
310
+ }
311
+
312
+ // Issue #7 - Absolute Windows paths will not parse at all
313
+ #[ should_panic( expected = "index out of bounds: the len is 1 but the index is 1" ) ]
314
+ #[ test]
315
+ fn absolute_windows_path ( ) {
316
+ let test_url = "c:\\ project-name.git" ;
317
+ let parsed = GitUrl :: parse ( test_url) . expect ( "URL parse failed" ) ;
318
+ let expected = GitUrl {
319
+ host : None ,
320
+ name : "project-name" . to_string ( ) ,
321
+ owner : None ,
322
+ organization : None ,
323
+ fullname : "project-name" . to_string ( ) ,
324
+ scheme : Scheme :: File ,
325
+ user : None ,
279
326
token : None ,
280
327
port : None ,
281
- path : ".. \\ project-name.git" . to_string ( ) ,
328
+ path : "c: \\ project-name.git" . to_string ( ) ,
282
329
git_suffix : true ,
283
330
scheme_prefix : true ,
284
331
} ;
285
332
286
333
assert_eq ! ( parsed, expected) ;
287
- }
334
+ }
0 commit comments