Przeglądaj źródła

Rename utf8_percent_encode_to to utf8_percent_encode

… to be consistent with percent_encode vs. percent_encode_to.
Simon Sapin 12 lat temu
rodzic
commit
8927aad583
2 zmienionych plików z 9 dodań i 9 usunięć
  1. 6 6
      src/parser.rs
  2. 3 3
      src/url.rs

+ 6 - 6
src/parser.rs

@@ -15,7 +15,7 @@ use encoding;
 use super::{
     ParseResult, UrlParser, Url, RelativeSchemeData, OtherSchemeData, Host, Domain,
     SchemeType, FileLikeScheme, RelativeScheme, NonRelativeScheme,
-    utf8_percent_encode, percent_encode};
+    utf8_percent_encode_to, percent_encode};
 use encode_sets::{SIMPLE_ENCODE_SET, DEFAULT_ENCODE_SET, USERINFO_ENCODE_SET, QUERY_ENCODE_SET};
 
 
@@ -278,7 +278,7 @@ fn parse_userinfo<'a>(input: &'a str, parser: &UrlParser)
                 try!(check_url_code_point(input, i, c, parser));
                 // The spec says to use the default encode set,
                 // but also replaces '@' by '%40' in an earlier step.
-                utf8_percent_encode(input.slice(i, next_i),
+                utf8_percent_encode_to(input.slice(i, next_i),
                                     USERINFO_ENCODE_SET, &mut username);
             }
         }
@@ -296,7 +296,7 @@ fn parse_password(input: &str, parser: &UrlParser) -> ParseResult<String> {
                 try!(check_url_code_point(input, i, c, parser));
                 // The spec says to use the default encode set,
                 // but also replaces '@' by '%40' in an earlier step.
-                utf8_percent_encode(input.slice(i, next_i),
+                utf8_percent_encode_to(input.slice(i, next_i),
                                     USERINFO_ENCODE_SET, &mut password);
             }
         }
@@ -458,7 +458,7 @@ fn parse_path<'a>(base_path: &[String], input: &'a str, context: Context,
                 '\t' | '\n' | '\r' => try!(parser.parse_error("Invalid character")),
                 _ => {
                     try!(check_url_code_point(input, i, c, parser));
-                    utf8_percent_encode(input.slice(i, next_i),
+                    utf8_percent_encode_to(input.slice(i, next_i),
                                         DEFAULT_ENCODE_SET, &mut path_part);
                 }
             }
@@ -511,7 +511,7 @@ fn parse_scheme_data<'a>(input: &'a str, parser: &UrlParser)
             '\t' | '\n' | '\r' => try!(parser.parse_error("Invalid character")),
             _ => {
                 try!(check_url_code_point(input, i, c, parser));
-                utf8_percent_encode(input.slice(i, next_i),
+                utf8_percent_encode_to(input.slice(i, next_i),
                                     SIMPLE_ENCODE_SET, &mut scheme_data);
             }
         }
@@ -579,7 +579,7 @@ pub fn parse_fragment<'a>(input: &'a str, parser: &UrlParser) -> ParseResult<Str
             '\t' | '\n' | '\r' => try!(parser.parse_error("Invalid character")),
             _ => {
                 try!(check_url_code_point(input, i, c, parser));
-                utf8_percent_encode(input.slice(i, next_i),
+                utf8_percent_encode_to(input.slice(i, next_i),
                                     SIMPLE_ENCODE_SET, &mut fragment);
             }
         }

+ 3 - 3
src/url.rs

@@ -465,7 +465,7 @@ impl<'a> UrlUtils for UrlUtilsWrapper<'a> {
         match self.url.scheme_data {
             RelativeSchemeData(RelativeSchemeData { ref mut username, .. }) => {
                 username.truncate(0);
-                utf8_percent_encode(input, USERNAME_ENCODE_SET, username);
+                utf8_percent_encode_to(input, USERNAME_ENCODE_SET, username);
                 Ok(())
             },
             OtherSchemeData(_) => Err("Can not set username on non-relative URL.")
@@ -477,7 +477,7 @@ impl<'a> UrlUtils for UrlUtilsWrapper<'a> {
         match self.url.scheme_data {
             RelativeSchemeData(RelativeSchemeData { ref mut password, .. }) => {
                 let mut new_password = String::new();
-                utf8_percent_encode(input, PASSWORD_ENCODE_SET, &mut new_password);
+                utf8_percent_encode_to(input, PASSWORD_ENCODE_SET, &mut new_password);
                 *password = Some(new_password);
                 Ok(())
             },
@@ -815,7 +815,7 @@ fn from_hex(byte: u8) -> Option<u8> {
 
 
 #[inline]
-pub fn utf8_percent_encode(input: &str, encode_set: &[&str], output: &mut String) {
+pub fn utf8_percent_encode_to(input: &str, encode_set: &[&str], output: &mut String) {
     percent_encode_to(input.as_bytes(), encode_set, output)
 }