@@ -197,3 +197,138 @@ fn https_user_azure_devops() {
197197
198198 assert_eq ! ( parsed, expected) ;
199199}
200+
201+ #[ test]
202+ fn ftp_user ( ) {
203+ let test_url =
"ftp://[email protected] /user/project-name.git" ; 204+ let parsed = GitUrl :: parse ( test_url) . expect ( "URL parse failed" ) ;
205+ let expected = GitUrl {
206+ host : Some ( "host.tld" . to_string ( ) ) ,
207+ name : "project-name" . to_string ( ) ,
208+ owner : Some ( "user" . to_string ( ) ) ,
209+ organization : None ,
210+ fullname : "user/project-name" . to_string ( ) ,
211+ scheme : Scheme :: Ftp ,
212+ user : Some ( "git" . to_string ( ) ) ,
213+ token : None ,
214+ port : None ,
215+ path : "/user/project-name.git" . to_string ( ) ,
216+ git_suffix : true ,
217+ scheme_prefix : true ,
218+ } ;
219+
220+ assert_eq ! ( parsed, expected) ;
221+ }
222+
223+ #[ test]
224+ fn ftps_user ( ) {
225+ let test_url =
"ftps://[email protected] /user/project-name.git" ; 226+ let parsed = GitUrl :: parse ( test_url) . expect ( "URL parse failed" ) ;
227+ let expected = GitUrl {
228+ host : Some ( "host.tld" . to_string ( ) ) ,
229+ name : "project-name" . to_string ( ) ,
230+ owner : Some ( "user" . to_string ( ) ) ,
231+ organization : None ,
232+ fullname : "user/project-name" . to_string ( ) ,
233+ scheme : Scheme :: Ftps ,
234+ user : Some ( "git" . to_string ( ) ) ,
235+ token : None ,
236+ port : None ,
237+ path : "/user/project-name.git" . to_string ( ) ,
238+ git_suffix : true ,
239+ scheme_prefix : true ,
240+ } ;
241+
242+ assert_eq ! ( parsed, expected) ;
243+ }
244+
245+ #[ test]
246+ fn relative_unix_path ( ) {
247+ let test_url = "../project-name.git" ;
248+ let parsed = GitUrl :: parse ( test_url) . expect ( "URL parse failed" ) ;
249+ let expected = GitUrl {
250+ host : None ,
251+ name : "project-name" . to_string ( ) ,
252+ owner : None ,
253+ organization : None ,
254+ fullname : "project-name" . to_string ( ) ,
255+ scheme : Scheme :: File ,
256+ user : None ,
257+ token : None ,
258+ port : None ,
259+ path : "../project-name.git" . to_string ( ) ,
260+ git_suffix : 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 ,
284+ } ;
285+
286+ assert_eq ! ( parsed, expected) ;
287+ }
288+
289+ // Issue #6 - Relative Windows paths will parse into Unix paths
290+ #[ test]
291+ fn relative_windows_path ( ) {
292+ let test_url = "..\\ project-name.git" ;
293+ let parsed = GitUrl :: parse ( test_url) . expect ( "URL parse failed" ) ;
294+ let expected = GitUrl {
295+ host : None ,
296+ name : "project-name" . to_string ( ) ,
297+ owner : None ,
298+ organization : None ,
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 ,
326+ token : None ,
327+ port : None ,
328+ path : "c:\\ project-name.git" . to_string ( ) ,
329+ git_suffix : true ,
330+ scheme_prefix : true ,
331+ } ;
332+
333+ assert_eq ! ( parsed, expected) ;
334+ }
0 commit comments