Преглед изворни кода

Merge pull request #93 from valenting/empty_password

urlutils.rs - an empty password should be saved as None, not empty string
Simon Sapin пре 11 година
родитељ
комит
115e44c696
1 измењених фајлова са 4 додато и 0 уклоњено
  1. 4 0
      src/urlutils.rs

+ 4 - 0
src/urlutils.rs

@@ -65,6 +65,10 @@ impl<'a> UrlUtils for UrlUtilsWrapper<'a> {
     fn set_password(&mut self, input: &str) -> ParseResult<()> {
         match self.url.scheme_data {
             SchemeData::Relative(RelativeSchemeData { ref mut password, .. }) => {
+                if input.len() == 0 {
+                    *password = None;
+                    return Ok(());
+                }
                 let mut new_password = String::new();
                 utf8_percent_encode_to(input, PASSWORD_ENCODE_SET, &mut new_password);
                 *password = Some(new_password);