std: URLs without schemes parse as errors. Closes #3112

This commit is contained in:
Brian Anderson 2012-08-05 13:48:26 -07:00
parent a52f6d26db
commit dbf58716df

View file

@ -353,7 +353,7 @@ fn get_scheme(rawurl: ~str) -> result::result<(~str, ~str), @~str> {
}
}
};
return result::ok((copy rawurl, ~""));
return result::err(@~"url: Scheme must be terminated with a colon.");
}
// returns userinfo, host, port, and unparsed part, or an error
@ -779,6 +779,11 @@ mod tests {
assert option::unwrap(copy u.fragment) == ~"something";
}
#[test]
fn test_no_scheme() {
assert result::is_err(get_scheme(~"noschemehere.html"));
}
#[test]
fn test_invalid_scheme_errors() {
assert result::is_err(from_str(~"99://something"));