Skip to content

Instantly share code, notes, and snippets.

@KiChjang
Last active December 22, 2015 01:05
Show Gist options
  • Save KiChjang/f22b1dbac1b745c59fca to your computer and use it in GitHub Desktop.
Save KiChjang/f22b1dbac1b745c59fca to your computer and use it in GitHub Desktop.
// BEFORE
if authentication_fetch_flag {
let current_url = http_request.borrow().current_url();
if includes_credentials(current_url) {
authorization_value = Basic {
username: "",
password: None
};
if let Some(name) = current_url.username() {
authorization_value.username = name.to_owned();
}
if let Some(pass) = current_url.password() {
authorization_value.password = pass.to_owned();
}
}
}
// AFTER
if authentication_fetch_flag {
let current_url = http_request.borrow().current_url();
authorization_value = if includes_credentials(current_url) {
Some( Basic {
username: current_url.username().unwrap_or("").to_owned(),
password: current_url.password().map(to_owned)
})
} else { None };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment