@@ -83,21 +83,11 @@ impl LSPSUrl {
8383
8484 fn is_valid_url_char ( c : char ) -> bool {
8585 c. is_ascii_alphanumeric ( )
86- || matches ! (
87- c,
88- ':' | '/'
89- | '.' | '@' | '?'
90- | '#' | '%' | '-'
91- | '_' | '~' | '!'
92- | '$' | '&' | '\''
93- | '(' | ')' | '*'
94- | '+' | ',' | ';'
95- | '=' | ' '
96- )
86+ || matches ! ( c, ':' | '/' | '.' | '@' | '?' | '#' | '%' | '-' | '_' | '&' | '=' )
9787 }
9888
9989 fn is_valid_host_char ( c : char ) -> bool {
100- c. is_ascii_alphanumeric ( ) || matches ! ( c, '.' | '-' | ':' )
90+ c. is_ascii_alphanumeric ( ) || matches ! ( c, '.' | '-' | ':' | '_' )
10191 }
10292}
10393
@@ -138,8 +128,9 @@ mod tests {
138128 "https://example.com/search?q=test#results" ,
139129 "https://user:[email protected] /" , 140130 "https://192.168.1.1/admin" ,
141- "https://example.com/path with spaces" ,
142131 "https://example.com://path" ,
132+ "https://example.com/path%20with%20spaces" ,
133+ "https://example_example.com/path?query=with&spaces=true" ,
143134 ] ;
144135 for url_str in test_vec {
145136 let url = LSPSUrl :: parse ( url_str. to_string ( ) ) ;
@@ -160,6 +151,7 @@ mod tests {
160151 "a123+-.://example.com" ,
161152 "https:\\ \\ example.com\\ path" ,
162153 "https:///whatever" ,
154+ "https://example.com/path with spaces" ,
163155 ] ;
164156 for url_str in test_vec {
165157 let url = LSPSUrl :: parse ( url_str. to_string ( ) ) ;
@@ -206,9 +198,9 @@ mod tests {
206198 fn proptest_parse_round_trip(
207199 host in host_strategy( ) ,
208200 port in proptest:: option:: of( 0u16 ..=65535u16 ) ,
209- path in proptest:: option:: of( proptest:: string:: string_regex( "[a-zA-Z0-9._~%!$&()*+,; =:@/-]{0,20}" ) . unwrap( ) ) ,
210- query in proptest:: option:: of( proptest:: string:: string_regex( "[a-zA-Z0-9._~%!$&()*+,; =:@/-]{0,20}" ) . unwrap( ) ) ,
211- fragment in proptest:: option:: of( proptest:: string:: string_regex( "[a-zA-Z0-9._~%!$&()*+,; =:@/-]{0,20}" ) . unwrap( ) )
201+ path in proptest:: option:: of( proptest:: string:: string_regex( "[a-zA-Z0-9._%& =:@/-]{0,20}" ) . unwrap( ) ) ,
202+ query in proptest:: option:: of( proptest:: string:: string_regex( "[a-zA-Z0-9._%& =:@/-]{0,20}" ) . unwrap( ) ) ,
203+ fragment in proptest:: option:: of( proptest:: string:: string_regex( "[a-zA-Z0-9._%& =:@/-]{0,20}" ) . unwrap( ) )
212204 ) {
213205 let mut url = format!( "https://{}" , host) ;
214206 if let Some ( p) = port {
0 commit comments