Normalize some consecutive asterisks

This commit is contained in:
mtkennerly 2024-03-11 21:58:58 -04:00
parent 568c9dffda
commit a1efb2f3a3
No known key found for this signature in database
GPG key ID: E764BE00BE6E6408
2 changed files with 80 additions and 76 deletions

View file

@ -558,6 +558,8 @@ impl WikiPath {
}
static CONSECUTIVE_SLASHES: Lazy<Regex> = Lazy::new(|| Regex::new(r"/{2,}").unwrap());
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 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());
@ -568,6 +570,8 @@ impl WikiPath {
for (pattern, replacement) in [
(&CONSECUTIVE_SLASHES, "/"),
(&UNNECESSARY_DOUBLE_STAR_1, "${1}*"),
(&UNNECESSARY_DOUBLE_STAR_2, "*${1}"),
(&ENDING_WILDCARD, ""),
(&APP_DATA, placeholder::WIN_APP_DATA),
(&APP_DATA_ROAMING, placeholder::WIN_APP_DATA),