Skip to content

Commit

Permalink
Trim whitespace from sanitized directory names (#50)
Browse files Browse the repository at this point in the history
* Trim whitespace after sanitizing filenames

* Bump version to 0.15.1
  • Loading branch information
smbl64 authored Jul 28, 2024
1 parent 604bb20 commit a7c860d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "humble-cli"
authors = ["Mohammad Banisaeid <[email protected]>"]
version = "0.15.0"
version = "0.15.1"
license = "MIT"
description = "The missing CLI for downloading your Humble Bundle purchases"
documentation = "https://github.com/smbl64/humble-cli"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ After that you will have access to the following sub-commands:

```
$ humble-cli --help
humble-cli 0.15.0
humble-cli 0.15.1
The missing Humble Bundle CLI
USAGE:
Expand Down
15 changes: 11 additions & 4 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ pub fn replace_invalid_chars_in_filename(input: &str) -> String {
}
})
.collect::<String>()
.trim()
.to_string()
}

pub fn extract_filename_from_url(url: &str) -> Option<String> {
Expand Down Expand Up @@ -148,10 +150,15 @@ pub fn union_usize_ranges(values: &[&str], max_value: usize) -> Result<Vec<usize

#[test]
fn test_remove_invalid_chars() {
assert_eq!(
replace_invalid_chars_in_filename("Humble Bundle: Nice book"),
"Humble Bundle Nice book".to_string()
);
let test_data = vec![
("Humble Bundle: Nice book", "Humble Bundle Nice book"),
("::Make::", "Make"),
];

for (input, expected) in test_data {
let got = replace_invalid_chars_in_filename(input);
assert_eq!(expected, got);
}
}

#[test]
Expand Down

0 comments on commit a7c860d

Please sign in to comment.