Skip to content

Commit

Permalink
Fix errors when using root (/) as TARGET_DIR (#25)
Browse files Browse the repository at this point in the history
Previously, using `/` as `TARGET_DIR` lead to a situation where the
string got converted to an empty string when trimming away the trailing
slashes.

This PR fixes the issue by updating the `trim_trailing_slash` method to
skip trimming for strings with length `1`.

Co-authored-by: {{NAME}} <{{EMAIL}}>
  • Loading branch information
kesslern authored Jan 27, 2021
1 parent 3fb9785 commit 826d9ee
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,11 @@ impl<'a> Arguments<'a> {

fn trim_trailing_slash(string: &str) -> &str {
if let Some(b'/') = string.as_bytes().last() {
&string[..string.len() - 1]
if string.len() == 1 {
string
} else {
&string[..string.len() - 1]
}
} else {
string
}
Expand Down

0 comments on commit 826d9ee

Please sign in to comment.