about summary refs log tree commit diff
path: root/src/liburl/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/liburl/lib.rs')
-rw-r--r--src/liburl/lib.rs414
1 files changed, 207 insertions, 207 deletions
diff --git a/src/liburl/lib.rs b/src/liburl/lib.rs
index e02993fc1c5..b049246ca18 100644
--- a/src/liburl/lib.rs
+++ b/src/liburl/lib.rs
@@ -39,13 +39,13 @@ use std::uint;
 /// ```rust
 /// use url::{Url, UserInfo};
 ///
-/// let url = Url { scheme: "https".to_strbuf(),
-///                 user: Some(UserInfo { user: "username".to_strbuf(), pass: None }),
-///                 host: "example.com".to_strbuf(),
-///                 port: Some("8080".to_strbuf()),
-///                 path: "/foo/bar".to_strbuf(),
-///                 query: vec!(("baz".to_strbuf(), "qux".to_strbuf())),
-///                 fragment: Some("quz".to_strbuf()) };
+/// let url = Url { scheme: "https".to_string(),
+///                 user: Some(UserInfo { user: "username".to_string(), pass: None }),
+///                 host: "example.com".to_string(),
+///                 port: Some("8080".to_string()),
+///                 path: "/foo/bar".to_string(),
+///                 query: vec!(("baz".to_string(), "qux".to_string())),
+///                 fragment: Some("quz".to_string()) };
 /// // https://username@example.com:8080/foo/bar?baz=qux#quz
 /// ```
 #[deriving(Clone, Eq, TotalEq)]
@@ -61,7 +61,7 @@ pub struct Url {
     /// The path component of a URL, for example `/foo/bar`.
     pub path: String,
     /// The query component of a URL.
-    /// `vec!(("baz".to_strbuf(), "qux".to_strbuf()))` represents the fragment
+    /// `vec!(("baz".to_string(), "qux".to_string()))` represents the fragment
     /// `baz=qux` in the above example.
     pub query: Query,
     /// The fragment component, such as `quz`.  Doesn't include the leading `#` character.
@@ -73,7 +73,7 @@ pub struct Path {
     /// The path component of a URL, for example `/foo/bar`.
     pub path: String,
     /// The query component of a URL.
-    /// `vec!(("baz".to_strbuf(), "qux".to_strbuf()))` represents the fragment
+    /// `vec!(("baz".to_string(), "qux".to_string()))` represents the fragment
     /// `baz=qux` in the above example.
     pub query: Query,
     /// The fragment component, such as `quz`.  Doesn't include the leading `#` character.
@@ -417,10 +417,10 @@ fn split_char_first(s: &str, c: char) -> (String, String) {
         }
     }
     if index+mat == len {
-        return (s.slice(0, index).to_strbuf(), "".to_strbuf());
+        return (s.slice(0, index).to_string(), "".to_string());
     } else {
-        return (s.slice(0, index).to_strbuf(),
-                s.slice(index + mat, s.len()).to_strbuf());
+        return (s.slice(0, index).to_string(),
+                s.slice(index + mat, s.len()).to_string());
     }
 }
 
@@ -451,9 +451,9 @@ fn query_from_str(rawquery: &str) -> Query {
  * # Example
  *
  * ```rust
- * let query = vec!(("title".to_strbuf(), "The Village".to_strbuf()),
-                    ("north".to_strbuf(), "52.91".to_strbuf()),
-                    ("west".to_strbuf(), "4.10".to_strbuf()));
+ * let query = vec!(("title".to_string(), "The Village".to_string()),
+                    ("north".to_string(), "52.91".to_string()),
+                    ("west".to_string(), "4.10".to_string()));
  * println!("{}", url::query_to_str(&query));  // title=The%20Village&north=52.91&west=4.10
  * ```
  */
@@ -468,7 +468,7 @@ pub fn query_to_str(query: &Query) -> String {
         write!(&mut writer, "{}={}", encode_component(k.as_slice()),
                encode_component(v.as_slice()));
     }
-    str::from_utf8_lossy(writer.unwrap().as_slice()).to_strbuf()
+    str::from_utf8_lossy(writer.unwrap().as_slice()).to_string()
 }
 
 /**
@@ -483,7 +483,7 @@ pub fn query_to_str(query: &Query) -> String {
  *
  * let scheme = match get_scheme("https://example.com/") {
  *     Ok((sch, _)) => sch,
- *     Err(_) => "(None)".to_strbuf(),
+ *     Err(_) => "(None)".to_string(),
  * };
  * println!("Scheme in use: {}.", scheme); // Scheme in use: https.
  * ```
@@ -495,24 +495,24 @@ pub fn get_scheme(rawurl: &str) -> Result<(String, String), String> {
           '0' .. '9' | '+' | '-' | '.' => {
             if i == 0 {
                 return Err("url: Scheme must begin with a \
-                            letter.".to_strbuf());
+                            letter.".to_string());
             }
             continue;
           }
           ':' => {
             if i == 0 {
-                return Err("url: Scheme cannot be empty.".to_strbuf());
+                return Err("url: Scheme cannot be empty.".to_string());
             } else {
-                return Ok((rawurl.slice(0,i).to_strbuf(),
-                           rawurl.slice(i+1,rawurl.len()).to_strbuf()));
+                return Ok((rawurl.slice(0,i).to_string(),
+                           rawurl.slice(i+1,rawurl.len()).to_string()));
             }
           }
           _ => {
-            return Err("url: Invalid character in scheme.".to_strbuf());
+            return Err("url: Invalid character in scheme.".to_string());
           }
         }
     };
-    return Err("url: Scheme must be terminated with a colon.".to_strbuf());
+    return Err("url: Scheme must be terminated with a colon.".to_string());
 }
 
 #[deriving(Clone, Eq)]
@@ -527,7 +527,7 @@ fn get_authority(rawurl: &str) ->
     Result<(Option<UserInfo>, String, Option<String>, String), String> {
     if !rawurl.starts_with("//") {
         // there is no authority.
-        return Ok((None, "".to_strbuf(), None, rawurl.to_str().to_strbuf()));
+        return Ok((None, "".to_string(), None, rawurl.to_str().to_string()));
     }
 
     enum State {
@@ -544,7 +544,7 @@ fn get_authority(rawurl: &str) ->
     let mut input = Digit; // most restricted, start here.
 
     let mut userinfo = None;
-    let mut host = "".to_strbuf();
+    let mut host = "".to_string();
     let mut port = None;
 
     let mut colon_count = 0;
@@ -571,7 +571,7 @@ fn get_authority(rawurl: &str) ->
             // separators, don't change anything
           }
           _ => {
-            return Err("Illegal character in authority".to_strbuf());
+            return Err("Illegal character in authority".to_string());
           }
         }
 
@@ -588,7 +588,7 @@ fn get_authority(rawurl: &str) ->
                 // multiple colons means ipv6 address.
                 if input == Unreserved {
                     return Err(
-                        "Illegal characters in IPv6 address.".to_strbuf());
+                        "Illegal characters in IPv6 address.".to_string());
                 }
                 st = Ip6Host;
               }
@@ -596,7 +596,7 @@ fn get_authority(rawurl: &str) ->
                 pos = i;
                 if input == Unreserved {
                     // must be port
-                    host = rawurl.slice(begin, i).to_strbuf();
+                    host = rawurl.slice(begin, i).to_string();
                     st = InPort;
                 } else {
                     // can't be sure whether this is an ipv6 address or a port
@@ -606,19 +606,19 @@ fn get_authority(rawurl: &str) ->
               Ip6Port => {
                 if input == Unreserved {
                     return Err("Illegal characters in \
-                                authority.".to_strbuf());
+                                authority.".to_string());
                 }
                 st = Ip6Host;
               }
               Ip6Host => {
                 if colon_count > 7 {
-                    host = rawurl.slice(begin, i).to_strbuf();
+                    host = rawurl.slice(begin, i).to_string();
                     pos = i;
                     st = InPort;
                 }
               }
               _ => {
-                return Err("Invalid ':' in authority.".to_strbuf());
+                return Err("Invalid ':' in authority.".to_string());
               }
             }
             input = Digit; // reset input class
@@ -629,18 +629,18 @@ fn get_authority(rawurl: &str) ->
             colon_count = 0; // reset count
             match st {
               Start => {
-                let user = rawurl.slice(begin, i).to_strbuf();
+                let user = rawurl.slice(begin, i).to_string();
                 userinfo = Some(UserInfo::new(user, None));
                 st = InHost;
               }
               PassHostPort => {
-                let user = rawurl.slice(begin, pos).to_strbuf();
-                let pass = rawurl.slice(pos+1, i).to_strbuf();
+                let user = rawurl.slice(begin, pos).to_string();
+                let pass = rawurl.slice(pos+1, i).to_string();
                 userinfo = Some(UserInfo::new(user, Some(pass)));
                 st = InHost;
               }
               _ => {
-                return Err("Invalid '@' in authority.".to_strbuf());
+                return Err("Invalid '@' in authority.".to_string());
               }
             }
             begin = i+1;
@@ -657,27 +657,27 @@ fn get_authority(rawurl: &str) ->
     // finish up
     match st {
       Start => {
-        host = rawurl.slice(begin, end).to_strbuf();
+        host = rawurl.slice(begin, end).to_string();
       }
       PassHostPort | Ip6Port => {
         if input != Digit {
-            return Err("Non-digit characters in port.".to_strbuf());
+            return Err("Non-digit characters in port.".to_string());
         }
-        host = rawurl.slice(begin, pos).to_strbuf();
-        port = Some(rawurl.slice(pos+1, end).to_strbuf());
+        host = rawurl.slice(begin, pos).to_string();
+        port = Some(rawurl.slice(pos+1, end).to_string());
       }
       Ip6Host | InHost => {
-        host = rawurl.slice(begin, end).to_strbuf();
+        host = rawurl.slice(begin, end).to_string();
       }
       InPort => {
         if input != Digit {
-            return Err("Non-digit characters in port.".to_strbuf());
+            return Err("Non-digit characters in port.".to_string());
         }
-        port = Some(rawurl.slice(pos+1, end).to_strbuf());
+        port = Some(rawurl.slice(pos+1, end).to_string());
       }
     }
 
-    let rest = rawurl.slice(end, len).to_strbuf();
+    let rest = rawurl.slice(end, len).to_string();
     return Ok((userinfo, host, port, rest));
 }
 
@@ -698,19 +698,19 @@ fn get_path(rawurl: &str, authority: bool) ->
             end = i;
             break;
           }
-          _ => return Err("Invalid character in path.".to_strbuf())
+          _ => return Err("Invalid character in path.".to_string())
         }
     }
 
     if authority {
         if end != 0 && !rawurl.starts_with("/") {
             return Err("Non-empty path must begin with\
-                              '/' in presence of authority.".to_strbuf());
+                              '/' in presence of authority.".to_string());
         }
     }
 
     return Ok((decode_component(rawurl.slice(0, end)),
-                    rawurl.slice(end, len).to_strbuf()));
+                    rawurl.slice(end, len).to_string()));
 }
 
 // returns the parsed query and the fragment, if present
@@ -888,53 +888,53 @@ impl<S: Writer> Hash<S> for Path {
 #[test]
 fn test_split_char_first() {
     let (u,v) = split_char_first("hello, sweet world", ',');
-    assert_eq!(u, "hello".to_strbuf());
-    assert_eq!(v, " sweet world".to_strbuf());
+    assert_eq!(u, "hello".to_string());
+    assert_eq!(v, " sweet world".to_string());
 
     let (u,v) = split_char_first("hello sweet world", ',');
-    assert_eq!(u, "hello sweet world".to_strbuf());
-    assert_eq!(v, "".to_strbuf());
+    assert_eq!(u, "hello sweet world".to_string());
+    assert_eq!(v, "".to_string());
 }
 
 #[test]
 fn test_get_authority() {
     let (u, h, p, r) = get_authority(
         "//user:pass@rust-lang.org/something").unwrap();
-    assert_eq!(u, Some(UserInfo::new("user".to_strbuf(), Some("pass".to_strbuf()))));
-    assert_eq!(h, "rust-lang.org".to_strbuf());
+    assert_eq!(u, Some(UserInfo::new("user".to_string(), Some("pass".to_string()))));
+    assert_eq!(h, "rust-lang.org".to_string());
     assert!(p.is_none());
-    assert_eq!(r, "/something".to_strbuf());
+    assert_eq!(r, "/something".to_string());
 
     let (u, h, p, r) = get_authority(
         "//rust-lang.org:8000?something").unwrap();
     assert!(u.is_none());
-    assert_eq!(h, "rust-lang.org".to_strbuf());
-    assert_eq!(p, Some("8000".to_strbuf()));
-    assert_eq!(r, "?something".to_strbuf());
+    assert_eq!(h, "rust-lang.org".to_string());
+    assert_eq!(p, Some("8000".to_string()));
+    assert_eq!(r, "?something".to_string());
 
     let (u, h, p, r) = get_authority(
         "//rust-lang.org#blah").unwrap();
     assert!(u.is_none());
-    assert_eq!(h, "rust-lang.org".to_strbuf());
+    assert_eq!(h, "rust-lang.org".to_string());
     assert!(p.is_none());
-    assert_eq!(r, "#blah".to_strbuf());
+    assert_eq!(r, "#blah".to_string());
 
     // ipv6 tests
     let (_, h, _, _) = get_authority(
         "//2001:0db8:85a3:0042:0000:8a2e:0370:7334#blah").unwrap();
-    assert_eq!(h, "2001:0db8:85a3:0042:0000:8a2e:0370:7334".to_strbuf());
+    assert_eq!(h, "2001:0db8:85a3:0042:0000:8a2e:0370:7334".to_string());
 
     let (_, h, p, _) = get_authority(
         "//2001:0db8:85a3:0042:0000:8a2e:0370:7334:8000#blah").unwrap();
-    assert_eq!(h, "2001:0db8:85a3:0042:0000:8a2e:0370:7334".to_strbuf());
-    assert_eq!(p, Some("8000".to_strbuf()));
+    assert_eq!(h, "2001:0db8:85a3:0042:0000:8a2e:0370:7334".to_string());
+    assert_eq!(p, Some("8000".to_string()));
 
     let (u, h, p, _) = get_authority(
         "//us:p@2001:0db8:85a3:0042:0000:8a2e:0370:7334:8000#blah"
     ).unwrap();
-    assert_eq!(u, Some(UserInfo::new("us".to_strbuf(), Some("p".to_strbuf()))));
-    assert_eq!(h, "2001:0db8:85a3:0042:0000:8a2e:0370:7334".to_strbuf());
-    assert_eq!(p, Some("8000".to_strbuf()));
+    assert_eq!(u, Some(UserInfo::new("us".to_string(), Some("p".to_string()))));
+    assert_eq!(h, "2001:0db8:85a3:0042:0000:8a2e:0370:7334".to_string());
+    assert_eq!(p, Some("8000".to_string()));
 
     // invalid authorities;
     assert!(get_authority("//user:pass@rust-lang:something").is_err());
@@ -946,22 +946,22 @@ fn test_get_authority() {
 
     // these parse as empty, because they don't start with '//'
     let (_, h, _, _) = get_authority("user:pass@rust-lang").unwrap();
-    assert_eq!(h, "".to_strbuf());
+    assert_eq!(h, "".to_string());
     let (_, h, _, _) = get_authority("rust-lang.org").unwrap();
-    assert_eq!(h, "".to_strbuf());
+    assert_eq!(h, "".to_string());
 }
 
 #[test]
 fn test_get_path() {
     let (p, r) = get_path("/something+%20orother", true).unwrap();
-    assert_eq!(p, "/something+ orother".to_strbuf());
-    assert_eq!(r, "".to_strbuf());
+    assert_eq!(p, "/something+ orother".to_string());
+    assert_eq!(r, "".to_string());
     let (p, r) = get_path("test@email.com#fragment", false).unwrap();
-    assert_eq!(p, "test@email.com".to_strbuf());
-    assert_eq!(r, "#fragment".to_strbuf());
+    assert_eq!(p, "test@email.com".to_string());
+    assert_eq!(r, "#fragment".to_string());
     let (p, r) = get_path("/gen/:addr=?q=v", false).unwrap();
-    assert_eq!(p, "/gen/:addr=".to_strbuf());
-    assert_eq!(r, "?q=v".to_strbuf());
+    assert_eq!(p, "/gen/:addr=".to_string());
+    assert_eq!(r, "?q=v".to_string());
 
     //failure cases
     assert!(get_path("something?q", true).is_err());
@@ -981,13 +981,13 @@ mod tests {
 
         let up = from_str(url);
         let u = up.unwrap();
-        assert_eq!(&u.scheme, &"http".to_strbuf());
-        assert_eq!(&u.user, &Some(UserInfo::new("user".to_strbuf(), Some("pass".to_strbuf()))));
-        assert_eq!(&u.host, &"rust-lang.org".to_strbuf());
-        assert_eq!(&u.port, &Some("8080".to_strbuf()));
-        assert_eq!(&u.path, &"/doc/~u".to_strbuf());
-        assert_eq!(&u.query, &vec!(("s".to_strbuf(), "v".to_strbuf())));
-        assert_eq!(&u.fragment, &Some("something".to_strbuf()));
+        assert_eq!(&u.scheme, &"http".to_string());
+        assert_eq!(&u.user, &Some(UserInfo::new("user".to_string(), Some("pass".to_string()))));
+        assert_eq!(&u.host, &"rust-lang.org".to_string());
+        assert_eq!(&u.port, &Some("8080".to_string()));
+        assert_eq!(&u.path, &"/doc/~u".to_string());
+        assert_eq!(&u.query, &vec!(("s".to_string(), "v".to_string())));
+        assert_eq!(&u.fragment, &Some("something".to_string()));
     }
 
     #[test]
@@ -996,69 +996,69 @@ mod tests {
 
         let up = path_from_str(path);
         let u = up.unwrap();
-        assert_eq!(&u.path, &"/doc/~u".to_strbuf());
-        assert_eq!(&u.query, &vec!(("s".to_strbuf(), "v".to_strbuf())));
-        assert_eq!(&u.fragment, &Some("something".to_strbuf()));
+        assert_eq!(&u.path, &"/doc/~u".to_string());
+        assert_eq!(&u.query, &vec!(("s".to_string(), "v".to_string())));
+        assert_eq!(&u.fragment, &Some("something".to_string()));
     }
 
     #[test]
     fn test_url_parse_host_slash() {
         let urlstr = "http://0.42.42.42/";
         let url = from_str(urlstr).unwrap();
-        assert!(url.host == "0.42.42.42".to_strbuf());
-        assert!(url.path == "/".to_strbuf());
+        assert!(url.host == "0.42.42.42".to_string());
+        assert!(url.path == "/".to_string());
     }
 
     #[test]
     fn test_path_parse_host_slash() {
         let pathstr = "/";
         let path = path_from_str(pathstr).unwrap();
-        assert!(path.path == "/".to_strbuf());
+        assert!(path.path == "/".to_string());
     }
 
     #[test]
     fn test_url_host_with_port() {
         let urlstr = "scheme://host:1234";
         let url = from_str(urlstr).unwrap();
-        assert_eq!(&url.scheme, &"scheme".to_strbuf());
-        assert_eq!(&url.host, &"host".to_strbuf());
-        assert_eq!(&url.port, &Some("1234".to_strbuf()));
+        assert_eq!(&url.scheme, &"scheme".to_string());
+        assert_eq!(&url.host, &"host".to_string());
+        assert_eq!(&url.port, &Some("1234".to_string()));
         // is empty path really correct? Other tests think so
-        assert_eq!(&url.path, &"".to_strbuf());
+        assert_eq!(&url.path, &"".to_string());
         let urlstr = "scheme://host:1234/";
         let url = from_str(urlstr).unwrap();
-        assert_eq!(&url.scheme, &"scheme".to_strbuf());
-        assert_eq!(&url.host, &"host".to_strbuf());
-        assert_eq!(&url.port, &Some("1234".to_strbuf()));
-        assert_eq!(&url.path, &"/".to_strbuf());
+        assert_eq!(&url.scheme, &"scheme".to_string());
+        assert_eq!(&url.host, &"host".to_string());
+        assert_eq!(&url.port, &Some("1234".to_string()));
+        assert_eq!(&url.path, &"/".to_string());
     }
 
     #[test]
     fn test_url_with_underscores() {
         let urlstr = "http://dotcom.com/file_name.html";
         let url = from_str(urlstr).unwrap();
-        assert!(url.path == "/file_name.html".to_strbuf());
+        assert!(url.path == "/file_name.html".to_string());
     }
 
     #[test]
     fn test_path_with_underscores() {
         let pathstr = "/file_name.html";
         let path = path_from_str(pathstr).unwrap();
-        assert!(path.path == "/file_name.html".to_strbuf());
+        assert!(path.path == "/file_name.html".to_string());
     }
 
     #[test]
     fn test_url_with_dashes() {
         let urlstr = "http://dotcom.com/file-name.html";
         let url = from_str(urlstr).unwrap();
-        assert!(url.path == "/file-name.html".to_strbuf());
+        assert!(url.path == "/file-name.html".to_string());
     }
 
     #[test]
     fn test_path_with_dashes() {
         let pathstr = "/file-name.html";
         let path = path_from_str(pathstr).unwrap();
-        assert!(path.path == "/file-name.html".to_strbuf());
+        assert!(path.path == "/file-name.html".to_string());
     }
 
     #[test]
@@ -1137,16 +1137,16 @@ mod tests {
     fn test_url_component_encoding() {
         let url = "http://rust-lang.org/doc%20uments?ba%25d%20=%23%26%2B";
         let u = from_str(url).unwrap();
-        assert!(u.path == "/doc uments".to_strbuf());
-        assert!(u.query == vec!(("ba%d ".to_strbuf(), "#&+".to_strbuf())));
+        assert!(u.path == "/doc uments".to_string());
+        assert!(u.query == vec!(("ba%d ".to_string(), "#&+".to_string())));
     }
 
     #[test]
     fn test_path_component_encoding() {
         let path = "/doc%20uments?ba%25d%20=%23%26%2B";
         let p = path_from_str(path).unwrap();
-        assert!(p.path == "/doc uments".to_strbuf());
-        assert!(p.query == vec!(("ba%d ".to_strbuf(), "#&+".to_strbuf())));
+        assert!(p.path == "/doc uments".to_string());
+        assert!(p.query == vec!(("ba%d ".to_string(), "#&+".to_string())));
     }
 
     #[test]
@@ -1157,134 +1157,134 @@ mod tests {
 
     #[test]
     fn test_encode() {
-        assert_eq!(encode(""), "".to_strbuf());
-        assert_eq!(encode("http://example.com"), "http://example.com".to_strbuf());
-        assert_eq!(encode("foo bar% baz"), "foo%20bar%25%20baz".to_strbuf());
-        assert_eq!(encode(" "), "%20".to_strbuf());
-        assert_eq!(encode("!"), "!".to_strbuf());
-        assert_eq!(encode("\""), "\"".to_strbuf());
-        assert_eq!(encode("#"), "#".to_strbuf());
-        assert_eq!(encode("$"), "$".to_strbuf());
-        assert_eq!(encode("%"), "%25".to_strbuf());
-        assert_eq!(encode("&"), "&".to_strbuf());
-        assert_eq!(encode("'"), "%27".to_strbuf());
-        assert_eq!(encode("("), "(".to_strbuf());
-        assert_eq!(encode(")"), ")".to_strbuf());
-        assert_eq!(encode("*"), "*".to_strbuf());
-        assert_eq!(encode("+"), "+".to_strbuf());
-        assert_eq!(encode(","), ",".to_strbuf());
-        assert_eq!(encode("/"), "/".to_strbuf());
-        assert_eq!(encode(":"), ":".to_strbuf());
-        assert_eq!(encode(";"), ";".to_strbuf());
-        assert_eq!(encode("="), "=".to_strbuf());
-        assert_eq!(encode("?"), "?".to_strbuf());
-        assert_eq!(encode("@"), "@".to_strbuf());
-        assert_eq!(encode("["), "[".to_strbuf());
-        assert_eq!(encode("]"), "]".to_strbuf());
+        assert_eq!(encode(""), "".to_string());
+        assert_eq!(encode("http://example.com"), "http://example.com".to_string());
+        assert_eq!(encode("foo bar% baz"), "foo%20bar%25%20baz".to_string());
+        assert_eq!(encode(" "), "%20".to_string());
+        assert_eq!(encode("!"), "!".to_string());
+        assert_eq!(encode("\""), "\"".to_string());
+        assert_eq!(encode("#"), "#".to_string());
+        assert_eq!(encode("$"), "$".to_string());
+        assert_eq!(encode("%"), "%25".to_string());
+        assert_eq!(encode("&"), "&".to_string());
+        assert_eq!(encode("'"), "%27".to_string());
+        assert_eq!(encode("("), "(".to_string());
+        assert_eq!(encode(")"), ")".to_string());
+        assert_eq!(encode("*"), "*".to_string());
+        assert_eq!(encode("+"), "+".to_string());
+        assert_eq!(encode(","), ",".to_string());
+        assert_eq!(encode("/"), "/".to_string());
+        assert_eq!(encode(":"), ":".to_string());
+        assert_eq!(encode(";"), ";".to_string());
+        assert_eq!(encode("="), "=".to_string());
+        assert_eq!(encode("?"), "?".to_string());
+        assert_eq!(encode("@"), "@".to_string());
+        assert_eq!(encode("["), "[".to_string());
+        assert_eq!(encode("]"), "]".to_string());
     }
 
     #[test]
     fn test_encode_component() {
-        assert_eq!(encode_component(""), "".to_strbuf());
+        assert_eq!(encode_component(""), "".to_string());
         assert!(encode_component("http://example.com") ==
-            "http%3A%2F%2Fexample.com".to_strbuf());
+            "http%3A%2F%2Fexample.com".to_string());
         assert!(encode_component("foo bar% baz") ==
-            "foo%20bar%25%20baz".to_strbuf());
-        assert_eq!(encode_component(" "), "%20".to_strbuf());
-        assert_eq!(encode_component("!"), "%21".to_strbuf());
-        assert_eq!(encode_component("#"), "%23".to_strbuf());
-        assert_eq!(encode_component("$"), "%24".to_strbuf());
-        assert_eq!(encode_component("%"), "%25".to_strbuf());
-        assert_eq!(encode_component("&"), "%26".to_strbuf());
-        assert_eq!(encode_component("'"), "%27".to_strbuf());
-        assert_eq!(encode_component("("), "%28".to_strbuf());
-        assert_eq!(encode_component(")"), "%29".to_strbuf());
-        assert_eq!(encode_component("*"), "%2A".to_strbuf());
-        assert_eq!(encode_component("+"), "%2B".to_strbuf());
-        assert_eq!(encode_component(","), "%2C".to_strbuf());
-        assert_eq!(encode_component("/"), "%2F".to_strbuf());
-        assert_eq!(encode_component(":"), "%3A".to_strbuf());
-        assert_eq!(encode_component(";"), "%3B".to_strbuf());
-        assert_eq!(encode_component("="), "%3D".to_strbuf());
-        assert_eq!(encode_component("?"), "%3F".to_strbuf());
-        assert_eq!(encode_component("@"), "%40".to_strbuf());
-        assert_eq!(encode_component("["), "%5B".to_strbuf());
-        assert_eq!(encode_component("]"), "%5D".to_strbuf());
+            "foo%20bar%25%20baz".to_string());
+        assert_eq!(encode_component(" "), "%20".to_string());
+        assert_eq!(encode_component("!"), "%21".to_string());
+        assert_eq!(encode_component("#"), "%23".to_string());
+        assert_eq!(encode_component("$"), "%24".to_string());
+        assert_eq!(encode_component("%"), "%25".to_string());
+        assert_eq!(encode_component("&"), "%26".to_string());
+        assert_eq!(encode_component("'"), "%27".to_string());
+        assert_eq!(encode_component("("), "%28".to_string());
+        assert_eq!(encode_component(")"), "%29".to_string());
+        assert_eq!(encode_component("*"), "%2A".to_string());
+        assert_eq!(encode_component("+"), "%2B".to_string());
+        assert_eq!(encode_component(","), "%2C".to_string());
+        assert_eq!(encode_component("/"), "%2F".to_string());
+        assert_eq!(encode_component(":"), "%3A".to_string());
+        assert_eq!(encode_component(";"), "%3B".to_string());
+        assert_eq!(encode_component("="), "%3D".to_string());
+        assert_eq!(encode_component("?"), "%3F".to_string());
+        assert_eq!(encode_component("@"), "%40".to_string());
+        assert_eq!(encode_component("["), "%5B".to_string());
+        assert_eq!(encode_component("]"), "%5D".to_string());
     }
 
     #[test]
     fn test_decode() {
-        assert_eq!(decode(""), "".to_strbuf());
-        assert_eq!(decode("abc/def 123"), "abc/def 123".to_strbuf());
-        assert_eq!(decode("abc%2Fdef%20123"), "abc%2Fdef 123".to_strbuf());
-        assert_eq!(decode("%20"), " ".to_strbuf());
-        assert_eq!(decode("%21"), "%21".to_strbuf());
-        assert_eq!(decode("%22"), "%22".to_strbuf());
-        assert_eq!(decode("%23"), "%23".to_strbuf());
-        assert_eq!(decode("%24"), "%24".to_strbuf());
-        assert_eq!(decode("%25"), "%".to_strbuf());
-        assert_eq!(decode("%26"), "%26".to_strbuf());
-        assert_eq!(decode("%27"), "'".to_strbuf());
-        assert_eq!(decode("%28"), "%28".to_strbuf());
-        assert_eq!(decode("%29"), "%29".to_strbuf());
-        assert_eq!(decode("%2A"), "%2A".to_strbuf());
-        assert_eq!(decode("%2B"), "%2B".to_strbuf());
-        assert_eq!(decode("%2C"), "%2C".to_strbuf());
-        assert_eq!(decode("%2F"), "%2F".to_strbuf());
-        assert_eq!(decode("%3A"), "%3A".to_strbuf());
-        assert_eq!(decode("%3B"), "%3B".to_strbuf());
-        assert_eq!(decode("%3D"), "%3D".to_strbuf());
-        assert_eq!(decode("%3F"), "%3F".to_strbuf());
-        assert_eq!(decode("%40"), "%40".to_strbuf());
-        assert_eq!(decode("%5B"), "%5B".to_strbuf());
-        assert_eq!(decode("%5D"), "%5D".to_strbuf());
+        assert_eq!(decode(""), "".to_string());
+        assert_eq!(decode("abc/def 123"), "abc/def 123".to_string());
+        assert_eq!(decode("abc%2Fdef%20123"), "abc%2Fdef 123".to_string());
+        assert_eq!(decode("%20"), " ".to_string());
+        assert_eq!(decode("%21"), "%21".to_string());
+        assert_eq!(decode("%22"), "%22".to_string());
+        assert_eq!(decode("%23"), "%23".to_string());
+        assert_eq!(decode("%24"), "%24".to_string());
+        assert_eq!(decode("%25"), "%".to_string());
+        assert_eq!(decode("%26"), "%26".to_string());
+        assert_eq!(decode("%27"), "'".to_string());
+        assert_eq!(decode("%28"), "%28".to_string());
+        assert_eq!(decode("%29"), "%29".to_string());
+        assert_eq!(decode("%2A"), "%2A".to_string());
+        assert_eq!(decode("%2B"), "%2B".to_string());
+        assert_eq!(decode("%2C"), "%2C".to_string());
+        assert_eq!(decode("%2F"), "%2F".to_string());
+        assert_eq!(decode("%3A"), "%3A".to_string());
+        assert_eq!(decode("%3B"), "%3B".to_string());
+        assert_eq!(decode("%3D"), "%3D".to_string());
+        assert_eq!(decode("%3F"), "%3F".to_string());
+        assert_eq!(decode("%40"), "%40".to_string());
+        assert_eq!(decode("%5B"), "%5B".to_string());
+        assert_eq!(decode("%5D"), "%5D".to_string());
     }
 
     #[test]
     fn test_decode_component() {
-        assert_eq!(decode_component(""), "".to_strbuf());
-        assert_eq!(decode_component("abc/def 123"), "abc/def 123".to_strbuf());
-        assert_eq!(decode_component("abc%2Fdef%20123"), "abc/def 123".to_strbuf());
-        assert_eq!(decode_component("%20"), " ".to_strbuf());
-        assert_eq!(decode_component("%21"), "!".to_strbuf());
-        assert_eq!(decode_component("%22"), "\"".to_strbuf());
-        assert_eq!(decode_component("%23"), "#".to_strbuf());
-        assert_eq!(decode_component("%24"), "$".to_strbuf());
-        assert_eq!(decode_component("%25"), "%".to_strbuf());
-        assert_eq!(decode_component("%26"), "&".to_strbuf());
-        assert_eq!(decode_component("%27"), "'".to_strbuf());
-        assert_eq!(decode_component("%28"), "(".to_strbuf());
-        assert_eq!(decode_component("%29"), ")".to_strbuf());
-        assert_eq!(decode_component("%2A"), "*".to_strbuf());
-        assert_eq!(decode_component("%2B"), "+".to_strbuf());
-        assert_eq!(decode_component("%2C"), ",".to_strbuf());
-        assert_eq!(decode_component("%2F"), "/".to_strbuf());
-        assert_eq!(decode_component("%3A"), ":".to_strbuf());
-        assert_eq!(decode_component("%3B"), ";".to_strbuf());
-        assert_eq!(decode_component("%3D"), "=".to_strbuf());
-        assert_eq!(decode_component("%3F"), "?".to_strbuf());
-        assert_eq!(decode_component("%40"), "@".to_strbuf());
-        assert_eq!(decode_component("%5B"), "[".to_strbuf());
-        assert_eq!(decode_component("%5D"), "]".to_strbuf());
+        assert_eq!(decode_component(""), "".to_string());
+        assert_eq!(decode_component("abc/def 123"), "abc/def 123".to_string());
+        assert_eq!(decode_component("abc%2Fdef%20123"), "abc/def 123".to_string());
+        assert_eq!(decode_component("%20"), " ".to_string());
+        assert_eq!(decode_component("%21"), "!".to_string());
+        assert_eq!(decode_component("%22"), "\"".to_string());
+        assert_eq!(decode_component("%23"), "#".to_string());
+        assert_eq!(decode_component("%24"), "$".to_string());
+        assert_eq!(decode_component("%25"), "%".to_string());
+        assert_eq!(decode_component("%26"), "&".to_string());
+        assert_eq!(decode_component("%27"), "'".to_string());
+        assert_eq!(decode_component("%28"), "(".to_string());
+        assert_eq!(decode_component("%29"), ")".to_string());
+        assert_eq!(decode_component("%2A"), "*".to_string());
+        assert_eq!(decode_component("%2B"), "+".to_string());
+        assert_eq!(decode_component("%2C"), ",".to_string());
+        assert_eq!(decode_component("%2F"), "/".to_string());
+        assert_eq!(decode_component("%3A"), ":".to_string());
+        assert_eq!(decode_component("%3B"), ";".to_string());
+        assert_eq!(decode_component("%3D"), "=".to_string());
+        assert_eq!(decode_component("%3F"), "?".to_string());
+        assert_eq!(decode_component("%40"), "@".to_string());
+        assert_eq!(decode_component("%5B"), "[".to_string());
+        assert_eq!(decode_component("%5D"), "]".to_string());
     }
 
     #[test]
     fn test_encode_form_urlencoded() {
         let mut m = HashMap::new();
-        assert_eq!(encode_form_urlencoded(&m), "".to_strbuf());
+        assert_eq!(encode_form_urlencoded(&m), "".to_string());
 
-        m.insert("".to_strbuf(), vec!());
-        m.insert("foo".to_strbuf(), vec!());
-        assert_eq!(encode_form_urlencoded(&m), "".to_strbuf());
+        m.insert("".to_string(), vec!());
+        m.insert("foo".to_string(), vec!());
+        assert_eq!(encode_form_urlencoded(&m), "".to_string());
 
         let mut m = HashMap::new();
-        m.insert("foo".to_strbuf(), vec!("bar".to_strbuf(), "123".to_strbuf()));
-        assert_eq!(encode_form_urlencoded(&m), "foo=bar&foo=123".to_strbuf());
+        m.insert("foo".to_string(), vec!("bar".to_string(), "123".to_string()));
+        assert_eq!(encode_form_urlencoded(&m), "foo=bar&foo=123".to_string());
 
         let mut m = HashMap::new();
-        m.insert("foo bar".to_strbuf(), vec!("abc".to_strbuf(), "12 = 34".to_strbuf()));
+        m.insert("foo bar".to_string(), vec!("abc".to_string(), "12 = 34".to_string()));
         assert!(encode_form_urlencoded(&m) ==
-            "foo+bar=abc&foo+bar=12+%3D+34".to_strbuf());
+            "foo+bar=abc&foo+bar=12+%3D+34".to_string());
     }
 
     #[test]
@@ -1294,8 +1294,8 @@ mod tests {
         let s = "a=1&foo+bar=abc&foo+bar=12+%3D+34".as_bytes();
         let form = decode_form_urlencoded(s);
         assert_eq!(form.len(), 2);
-        assert_eq!(form.get(&"a".to_strbuf()), &vec!("1".to_strbuf()));
-        assert_eq!(form.get(&"foo bar".to_strbuf()),
-                   &vec!("abc".to_strbuf(), "12 = 34".to_strbuf()));
+        assert_eq!(form.get(&"a".to_string()), &vec!("1".to_string()));
+        assert_eq!(form.get(&"foo bar".to_string()),
+                   &vec!("abc".to_string(), "12 = 34".to_string()));
     }
 }