Skip to content

Commit

Permalink
Resolves #844 by returning Ok(()) if username or password is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
chanced committed Jul 2, 2023
1 parent a3e07c7 commit b4ff992
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions url/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2088,6 +2088,9 @@ impl Url {
pub fn set_password(&mut self, password: Option<&str>) -> Result<(), ()> {
// has_host implies !cannot_be_a_base
if !self.has_host() || self.host() == Some(Host::Domain("")) || self.scheme() == "file" {
if password.is_none() || password == Some("") {
return Ok(());

Check warning on line 2092 in url/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

url/src/lib.rs#L2092

Added line #L2092 was not covered by tests
}
return Err(());
}
let password = password.unwrap_or_default();
Expand Down Expand Up @@ -2182,6 +2185,9 @@ impl Url {
pub fn set_username(&mut self, username: &str) -> Result<(), ()> {
// has_host implies !cannot_be_a_base
if !self.has_host() || self.host() == Some(Host::Domain("")) || self.scheme() == "file" {
if username.is_empty() {
return Ok(());

Check warning on line 2189 in url/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

url/src/lib.rs#L2189

Added line #L2189 was not covered by tests
}
return Err(());
}
let username_start = self.scheme_end + 3;
Expand Down

0 comments on commit b4ff992

Please sign in to comment.