From dbf58716dfe1dd502ea37d5a613847406a9736c9 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 5 Aug 2012 13:48:26 -0700 Subject: [PATCH] std: URLs without schemes parse as errors. Closes #3112 --- src/libstd/net_url.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libstd/net_url.rs b/src/libstd/net_url.rs index 5b0894744860..ac9d4b389f97 100644 --- a/src/libstd/net_url.rs +++ b/src/libstd/net_url.rs @@ -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"));