std: Parse underscores in url paths

This commit is contained in:
Brian Anderson 2012-08-06 13:12:49 -07:00
parent 03330baf9c
commit 1e3143b34e

View File

@ -537,7 +537,8 @@ fn get_path(rawurl: ~str, authority : bool) ->
for str::each_chari(rawurl) |i,c| {
match c {
'A' to 'Z' | 'a' to 'z' | '0' to '9' | '&' |'\'' | '(' | ')' | '.'
| '@' | ':' | '%' | '/' | '+' | '!' | '*' | ',' | ';' | '=' => {
| '@' | ':' | '%' | '/' | '+' | '!' | '*' | ',' | ';' | '='
| '_' => {
again;
}
'?' | '#' => {
@ -795,6 +796,14 @@ mod tests {
assert url.path == ~"/";
}
#[test]
fn test_url_with_underscores() {
let urlstr = ~"http://dotcom.com/file_name.html";
let url = from_str(urlstr).get();
#debug("url: %?", url);
assert url.path == ~"/file_name.html";
}
#[test]
fn test_no_scheme() {
assert result::is_err(get_scheme(~"noschemehere.html"));