Skip to content

Commit 1e3143b

Browse files
committed
std: Parse underscores in url paths
1 parent 03330ba commit 1e3143b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/libstd/net_url.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,8 @@ fn get_path(rawurl: ~str, authority : bool) ->
537537
for str::each_chari(rawurl) |i,c| {
538538
match c {
539539
'A' to 'Z' | 'a' to 'z' | '0' to '9' | '&' |'\'' | '(' | ')' | '.'
540-
| '@' | ':' | '%' | '/' | '+' | '!' | '*' | ',' | ';' | '=' => {
540+
| '@' | ':' | '%' | '/' | '+' | '!' | '*' | ',' | ';' | '='
541+
| '_' => {
541542
again;
542543
}
543544
'?' | '#' => {
@@ -795,6 +796,14 @@ mod tests {
795796
assert url.path == ~"/";
796797
}
797798

799+
#[test]
800+
fn test_url_with_underscores() {
801+
let urlstr = ~"http://dotcom.com/file_name.html";
802+
let url = from_str(urlstr).get();
803+
#debug("url: %?", url);
804+
assert url.path == ~"/file_name.html";
805+
}
806+
798807
#[test]
799808
fn test_no_scheme() {
800809
assert result::is_err(get_scheme(~"noschemehere.html"));

0 commit comments

Comments
 (0)