Skip to content

Commit

Permalink
Use pop instead of trim_end_matches
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkAndshark committed Feb 27, 2024
1 parent f70df5c commit 83cd23a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions martin/src/utils/utilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ pub fn parse_base_path(path: &str) -> MartinResult<String> {
return Err(BasePathError(path.to_string()));
}
if let Ok(uri) = path.parse::<Uri>() {
let mut result = uri.path();
while result.len() > 1 {
result = result.trim_end_matches('/');
let mut result = uri.path().to_string();
while result.chars().last().is_some_and(|v| v == '/') && result.len() > 1 {
result.pop();
}
return Ok(result.to_string());
return Ok(result);
}
Err(BasePathError(path.to_string()))
}
Expand All @@ -62,7 +62,7 @@ pub mod tests {
] {
match expected {
Some(v) => assert_eq!(v, parse_base_path(path).unwrap()),
None => assert!(parse_base_path(&path).is_err()),
None => assert!(parse_base_path(path).is_err()),
}
}
}
Expand Down

0 comments on commit 83cd23a

Please sign in to comment.