@@ -83,21 +83,11 @@ impl LSPSUrl {
83
83
84
84
fn is_valid_url_char ( c : char ) -> bool {
85
85
c. is_ascii_alphanumeric ( )
86
- || matches ! (
87
- c,
88
- ':' | '/'
89
- | '.' | '@' | '?'
90
- | '#' | '%' | '-'
91
- | '_' | '~' | '!'
92
- | '$' | '&' | '\''
93
- | '(' | ')' | '*'
94
- | '+' | ',' | ';'
95
- | '=' | ' '
96
- )
86
+ || matches ! ( c, ':' | '/' | '.' | '@' | '?' | '#' | '%' | '-' | '_' | '&' | '=' )
97
87
}
98
88
99
89
fn is_valid_host_char ( c : char ) -> bool {
100
- c. is_ascii_alphanumeric ( ) || matches ! ( c, '.' | '-' | ':' )
90
+ c. is_ascii_alphanumeric ( ) || matches ! ( c, '.' | '-' | ':' | '_' )
101
91
}
102
92
}
103
93
@@ -138,8 +128,9 @@ mod tests {
138
128
"https://example.com/search?q=test#results" ,
139
129
"https://user:[email protected] /" ,
140
130
"https://192.168.1.1/admin" ,
141
- "https://example.com/path with spaces" ,
142
131
"https://example.com://path" ,
132
+ "https://example.com/path%20with%20spaces" ,
133
+ "https://example_example.com/path?query=with&spaces=true" ,
143
134
] ;
144
135
for url_str in test_vec {
145
136
let url = LSPSUrl :: parse ( url_str. to_string ( ) ) ;
@@ -160,6 +151,7 @@ mod tests {
160
151
"a123+-.://example.com" ,
161
152
"https:\\ \\ example.com\\ path" ,
162
153
"https:///whatever" ,
154
+ "https://example.com/path with spaces" ,
163
155
] ;
164
156
for url_str in test_vec {
165
157
let url = LSPSUrl :: parse ( url_str. to_string ( ) ) ;
@@ -206,9 +198,9 @@ mod tests {
206
198
fn proptest_parse_round_trip(
207
199
host in host_strategy( ) ,
208
200
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( ) )
212
204
) {
213
205
let mut url = format!( "https://{}" , host) ;
214
206
if let Some ( p) = port {
0 commit comments