Skip to content

Commit

Permalink
minor refactor in escape_for_exclude
Browse files Browse the repository at this point in the history
  • Loading branch information
drdo committed Jul 18, 2024
1 parent 7d88909 commit 67722dd
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/restic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,17 +330,18 @@ pub fn escape_for_exclude(path: &str) -> Cow<str> {
escaped.push_str(left);
for c in right.chars() {
match c {
'*' => escaped.push_str("[*]"),
'?' => escaped.push_str("[?]"),
'[' => escaped.push_str("[[]"),
'*' | '?' | '[' => {
escaped.push('[');
escaped.push(c);
escaped.push(']');
}
'\\' => {
#[cfg(target_os = "windows")]
escaped.push('\\');
#[cfg(not(target_os = "windows"))]
escaped.push_str("\\\\");
}
'\r' => push_as_inverse_range(&mut escaped, '\r'),
'\n' => push_as_inverse_range(&mut escaped, '\n'),
'\r' | '\n' => push_as_inverse_range(&mut escaped, c),
c => escaped.push(c),
}
}
Expand Down

0 comments on commit 67722dd

Please sign in to comment.