Skip to content

Commit

Permalink
prevent strip if flag is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
rawdaGastan committed Oct 16, 2023
1 parent 966d202 commit a665697
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/pack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,21 @@ pub async fn pack<P: Into<PathBuf>, S: Store>(writer: Writer, store: S, root: P,

// building routing table from store information
for route in store.routes() {
let url = url::Url::parse(&route.url).expect("failed to parse store url");

let username = url.username();
let password = url.password().unwrap();
let stripped = format!("{}:{}@", username, password);
let stripped_url = str::replace(&route.url, &stripped, "");

let mut store_url = route.url;

if strip_password {
let url = url::Url::parse(&store_url).expect("failed to parse store url");
let username = url.username();
let password = url.password().unwrap();
let stripped = format!("{}:{}@", username, password);
store_url = str::replace(&store_url, &stripped, "");
}

writer
.route(
route.start.unwrap_or(u8::MIN),
route.end.unwrap_or(u8::MAX),
if strip_password { stripped_url } else { route.url },
store_url,
)
.await?;
}
Expand Down

0 comments on commit a665697

Please sign in to comment.