Skip to content

Commit

Permalink
Fix unavability of Windows custom rules
Browse files Browse the repository at this point in the history
  • Loading branch information
qarmin committed Jul 28, 2021
1 parent 267ada9 commit 0fe9753
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
15 changes: 1 addition & 14 deletions src/help_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,7 @@ pub static CHARACTER: &str = "/";

pub fn validate_name(before_name: String) -> String {
// TODO when trying to print text in middle of text, then caret change position, fix it

let mut after_name = before_name;
after_name = after_name.replace("\\", "");
if cfg!(target_family = "windows") {
after_name = after_name.replace("/", "");
after_name = after_name.replace("<", "");
after_name = after_name.replace(">", "");
after_name = after_name.replace(":", "");
after_name = after_name.replace("", "");
after_name = after_name.replace("|", "");
after_name = after_name.replace("?", "");
after_name = after_name.replace("*", "");
}
after_name
before_name.chars().filter(|e| *e != '\\' && *e != '/').collect::<String>()
}
pub fn validate_number(before_name: String) -> String {
before_name.chars().filter(|e| e.is_digit(10)).collect::<String>()
Expand Down
4 changes: 2 additions & 2 deletions src/rule_normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ mod test {

rule.rule_data.full_normalize = true;
assert_eq!(rule_normalize("Świstak.txt", &rule), "swistak.txt");
assert_eq!(rule_normalize("SŚFSÆŚFLASÆOW .t", &rule), "ssfsaesflasaeow t");
assert_eq!(rule_normalize("SŚFSÆŚFLASÆOW .t", &rule), "ssfsaesflasaeow .t");
assert_eq!(rule_normalize("ŚwSFS:F:F::F", &rule), "swsfs-f-f-f");
assert_eq!(rule_normalize(" ---- sf s sf- --", &rule), "sf s sf");
assert_eq!(rule_normalize("SFMWOMWOMWF SFaflwp", &rule), "sfmwomwomwf sfaflwp");
assert_eq!(rule_normalize("śfsśæśfsædŋę’’’’.txt", &rule), "sfssaesfsaednge-.txt");

rule.rule_data.full_normalize = false;
assert_eq!(rule_normalize("Świstak.txt", &rule), "Swistak.txt");
assert_eq!(rule_normalize("SŚFSÆŚFLASÆOW .t", &rule), "SSFSAESFLASAEOW t");
assert_eq!(rule_normalize("SŚFSÆŚFLASÆOW .t", &rule), "SSFSAESFLASAEOW .t");
assert_eq!(rule_normalize("ŚwSFS:F:F::F", &rule), "SwSFS-F-F-F");
assert_eq!(rule_normalize(" ---- sf s sf- --", &rule), "sf s sf");
assert_eq!(rule_normalize("SFMWOMWOMWF SFaflwp", &rule), "SFMWOMWOMWF SFaflwp");
Expand Down

0 comments on commit 0fe9753

Please sign in to comment.