@@ -247,41 +247,88 @@ fn relative_unix_path() {
247247 let test_url = "../project-name.git" ;
248248 let parsed = GitUrl :: parse ( test_url) . expect ( "URL parse failed" ) ;
249249 let expected = GitUrl {
250- host : Some ( "host.tld" . to_string ( ) ) ,
250+ host : None ,
251251 name : "project-name" . to_string ( ) ,
252- owner : Some ( "user" . to_string ( ) ) ,
252+ owner : None ,
253253 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 ,
257257 token : None ,
258258 port : None ,
259259 path : "../project-name.git" . to_string ( ) ,
260260 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 ,
262284 } ;
263285
264286 assert_eq ! ( parsed, expected) ;
265287}
266288
289+ // Issue #6 - Relative Windows paths will parse into Unix paths
267290#[ test]
268291fn relative_windows_path ( ) {
269292 let test_url = "..\\ project-name.git" ;
270293 let parsed = GitUrl :: parse ( test_url) . expect ( "URL parse failed" ) ;
271294 let expected = GitUrl {
272- host : Some ( "host.tld" . to_string ( ) ) ,
295+ host : None ,
273296 name : "project-name" . to_string ( ) ,
274- owner : Some ( "user" . to_string ( ) ) ,
297+ owner : None ,
275298 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 ,
279326 token : None ,
280327 port : None ,
281- path : ".. \\ project-name.git" . to_string ( ) ,
328+ path : "c: \\ project-name.git" . to_string ( ) ,
282329 git_suffix : true ,
283330 scheme_prefix : true ,
284331 } ;
285332
286333 assert_eq ! ( parsed, expected) ;
287- }
334+ }
0 commit comments