Normalize dot segments in paths
This commit is contained in:
parent
d132d15c21
commit
22bae27388
3 changed files with 411 additions and 462 deletions
|
@ -14,6 +14,8 @@ pub fn normalize(path: &str) -> String {
|
|||
static UNNECESSARY_DOUBLE_STAR_1: Lazy<Regex> = Lazy::new(|| Regex::new(r"([^/*])\*{2,}").unwrap());
|
||||
static UNNECESSARY_DOUBLE_STAR_2: Lazy<Regex> = Lazy::new(|| Regex::new(r"\*{2,}([^/*])").unwrap());
|
||||
static ENDING_WILDCARD: Lazy<Regex> = Lazy::new(|| Regex::new(r"(/\*)+$").unwrap());
|
||||
static ENDING_DOT: Lazy<Regex> = Lazy::new(|| Regex::new(r"(/\.)$").unwrap());
|
||||
static INTERMEDIATE_DOT: Lazy<Regex> = Lazy::new(|| Regex::new(r"(/\./)").unwrap());
|
||||
static APP_DATA: Lazy<Regex> = Lazy::new(|| Regex::new(r"(?i)%appdata%").unwrap());
|
||||
static APP_DATA_ROAMING: Lazy<Regex> = Lazy::new(|| Regex::new(r"(?i)%userprofile%/AppData/Roaming").unwrap());
|
||||
static APP_DATA_LOCAL: Lazy<Regex> = Lazy::new(|| Regex::new(r"(?i)%localappdata%").unwrap());
|
||||
|
@ -26,6 +28,8 @@ pub fn normalize(path: &str) -> String {
|
|||
(&UNNECESSARY_DOUBLE_STAR_1, "${1}*"),
|
||||
(&UNNECESSARY_DOUBLE_STAR_2, "*${1}"),
|
||||
(&ENDING_WILDCARD, ""),
|
||||
(&ENDING_DOT, ""),
|
||||
(&INTERMEDIATE_DOT, "/"),
|
||||
(&APP_DATA, placeholder::WIN_APP_DATA),
|
||||
(&APP_DATA_ROAMING, placeholder::WIN_APP_DATA),
|
||||
(&APP_DATA_LOCAL, placeholder::WIN_LOCAL_APP_DATA),
|
||||
|
@ -87,6 +91,8 @@ pub fn too_broad(path: &str) -> bool {
|
|||
|
||||
// Several games/episodes are grouped together here.
|
||||
for item in [
|
||||
format!("{HOME}/*/"),
|
||||
format!("{HOME}/**/"),
|
||||
format!("{WIN_DOCUMENTS}/Telltale Games/*/"),
|
||||
format!("{XDG_CONFIG}/unity3d/*"),
|
||||
format!("{XDG_DATA}/unity3d/*"),
|
||||
|
|
Reference in a new issue