11use bstr:: ByteSlice ;
22use git_url:: Scheme ;
33
4- use crate :: parse:: { assert_url_and, assert_url_roundtrip, url} ;
4+ use crate :: parse:: { assert_url_and, assert_url_roundtrip, url, url_alternate } ;
55
66#[ test]
77fn file_path_with_protocol ( ) -> crate :: Result {
@@ -13,15 +13,23 @@ fn file_path_with_protocol() -> crate::Result {
1313
1414#[ test]
1515fn file_path_without_protocol ( ) -> crate :: Result {
16- let url = assert_url_and ( "/path/to/git" , url ( Scheme :: File , None , None , None , b"/path/to/git" ) ) ?. to_bstring ( ) ;
17- assert_eq ! ( url, "file:///path/to/git" ) ;
16+ let url = assert_url_and (
17+ "/path/to/git" ,
18+ url_alternate ( Scheme :: File , None , None , None , b"/path/to/git" ) ,
19+ ) ?
20+ . to_bstring ( ) ;
21+ assert_eq ! ( url, "/path/to/git" ) ;
1822 Ok ( ( ) )
1923}
2024
2125#[ test]
2226fn no_username_expansion_for_file_paths_without_protocol ( ) -> crate :: Result {
23- let url = assert_url_and ( "~/path/to/git" , url ( Scheme :: File , None , None , None , b"~/path/to/git" ) ) ?. to_bstring ( ) ;
24- assert_eq ! ( url, "file://~/path/to/git" ) ;
27+ let url = assert_url_and (
28+ "~/path/to/git" ,
29+ url_alternate ( Scheme :: File , None , None , None , b"~/path/to/git" ) ,
30+ ) ?
31+ . to_bstring ( ) ;
32+ assert_eq ! ( url, "~/path/to/git" ) ;
2533 Ok ( ( ) )
2634}
2735#[ test]
@@ -35,62 +43,72 @@ fn no_username_expansion_for_file_paths_with_protocol() -> crate::Result {
3543#[ test]
3644fn non_utf8_file_path_without_protocol ( ) -> crate :: Result {
3745 let parsed = git_url:: parse ( b"/path/to\xff /git" . as_bstr ( ) ) ?;
38- assert_eq ! ( parsed, url( Scheme :: File , None , None , None , b"/path/to\xff /git" , ) ) ;
46+ assert_eq ! (
47+ parsed,
48+ url_alternate( Scheme :: File , None , None , None , b"/path/to\xff /git" , )
49+ ) ;
3950 let url_lossless = parsed. to_bstring ( ) ;
4051 assert_eq ! (
4152 url_lossless. to_string( ) ,
42- "file:// /path/to�/git" ,
53+ "/path/to�/git" ,
4354 "non-unicode is made unicode safe after conversion"
4455 ) ;
45- assert_eq ! ( url_lossless, & b"file:// /path/to\xff /git" [ ..] , "otherwise it's lossless" ) ;
56+ assert_eq ! ( url_lossless, & b"/path/to\xff /git" [ ..] , "otherwise it's lossless" ) ;
4657 Ok ( ( ) )
4758}
4859
4960#[ test]
5061fn relative_file_path_without_protocol ( ) -> crate :: Result {
5162 let parsed = assert_url_and (
5263 "../../path/to/git" ,
53- url ( Scheme :: File , None , None , None , b"../../path/to/git" ) ,
64+ url_alternate ( Scheme :: File , None , None , None , b"../../path/to/git" ) ,
65+ ) ?
66+ . to_bstring ( ) ;
67+ assert_eq ! ( parsed, "../../path/to/git" ) ;
68+ let url = assert_url_and (
69+ "path/to/git" ,
70+ url_alternate ( Scheme :: File , None , None , None , b"path/to/git" ) ,
5471 ) ?
5572 . to_bstring ( ) ;
56- assert_eq ! ( parsed, "file://../../path/to/git" ) ;
57- let url = assert_url_and ( "path/to/git" , url ( Scheme :: File , None , None , None , b"path/to/git" ) ) ?. to_bstring ( ) ;
58- assert_eq ! ( url, "file://path/to/git" ) ;
73+ assert_eq ! ( url, "path/to/git" ) ;
5974 Ok ( ( ) )
6075}
6176
6277#[ test]
6378fn interior_relative_file_path_without_protocol ( ) -> crate :: Result {
6479 let url = assert_url_and (
6580 "/abs/path/../../path/to/git" ,
66- url ( Scheme :: File , None , None , None , b"/abs/path/../../path/to/git" ) ,
81+ url_alternate ( Scheme :: File , None , None , None , b"/abs/path/../../path/to/git" ) ,
6782 ) ?
6883 . to_bstring ( ) ;
69- assert_eq ! ( url, "file:// /abs/path/../../path/to/git" ) ;
84+ assert_eq ! ( url, "/abs/path/../../path/to/git" ) ;
7085 Ok ( ( ) )
7186}
7287
7388mod windows {
7489 use git_url:: Scheme ;
7590
76- use crate :: parse:: { assert_url_and, assert_url_roundtrip, url} ;
91+ use crate :: parse:: { assert_url_and, assert_url_roundtrip, url, url_alternate } ;
7792
7893 #[ test]
7994 fn file_path_without_protocol ( ) -> crate :: Result {
80- let url =
81- assert_url_and ( "x:/path/to/git" , url ( Scheme :: File , None , None , None , b"x:/path/to/git" ) ) ?. to_bstring ( ) ;
82- assert_eq ! ( url, "file://x:/path/to/git" ) ;
95+ let url = assert_url_and (
96+ "x:/path/to/git" ,
97+ url_alternate ( Scheme :: File , None , None , None , b"x:/path/to/git" ) ,
98+ ) ?
99+ . to_bstring ( ) ;
100+ assert_eq ! ( url, "x:/path/to/git" ) ;
83101 Ok ( ( ) )
84102 }
85103
86104 #[ test]
87105 fn file_path_with_backslashes_without_protocol ( ) -> crate :: Result {
88106 let url = assert_url_and (
89107 "x:\\ path\\ to\\ git" ,
90- url ( Scheme :: File , None , None , None , b"x:\\ path\\ to\\ git" ) ,
108+ url_alternate ( Scheme :: File , None , None , None , b"x:\\ path\\ to\\ git" ) ,
91109 ) ?
92110 . to_bstring ( ) ;
93- assert_eq ! ( url, "file:// x:\\ path\\ to\\ git" ) ;
111+ assert_eq ! ( url, "x:\\ path\\ to\\ git" ) ;
94112 Ok ( ( ) )
95113 }
96114
0 commit comments