Skip to content

Commit dbf5871

Browse files
committed
std: URLs without schemes parse as errors. Closes #3112
1 parent a52f6d2 commit dbf5871

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/libstd/net_url.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ fn get_scheme(rawurl: ~str) -> result::result<(~str, ~str), @~str> {
353353
}
354354
}
355355
};
356-
return result::ok((copy rawurl, ~""));
356+
return result::err(@~"url: Scheme must be terminated with a colon.");
357357
}
358358
359359
// returns userinfo, host, port, and unparsed part, or an error
@@ -779,6 +779,11 @@ mod tests {
779779
assert option::unwrap(copy u.fragment) == ~"something";
780780
}
781781
782+
#[test]
783+
fn test_no_scheme() {
784+
assert result::is_err(get_scheme(~"noschemehere.html"));
785+
}
786+
782787
#[test]
783788
fn test_invalid_scheme_errors() {
784789
assert result::is_err(from_str(~"99://something"));

0 commit comments

Comments
 (0)