diff options
Diffstat (limited to 'crates/shirabe/src/util/platform.rs')
| -rw-r--r-- | crates/shirabe/src/util/platform.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/crates/shirabe/src/util/platform.rs b/crates/shirabe/src/util/platform.rs index 797bac2..7c9f569 100644 --- a/crates/shirabe/src/util/platform.rs +++ b/crates/shirabe/src/util/platform.rs @@ -101,11 +101,16 @@ impl Platform { ); } + // Regex pattern compatibility: + // The original pattern uses a conditional subpattern to make the trailing `%` required + // only for the `%VAR%` form. The Rust regex crate does not support conditionals, so the + // two forms are written as an explicit alternation: `$VAR` or `%VAR%`. Preg::replace_callback( - r"#^(\$|(?P<percent>%))(?P<var>\w++)(?(percent)%)(?P<path>.*)#", + r"#^(?:\$(?P<dvar>\w+)|%(?P<pvar>\w+)%)(?P<path>.*)#", |matches: &indexmap::IndexMap<CaptureKey, String>| -> String { let var = matches - .get(&CaptureKey::ByName("var".to_string())) + .get(&CaptureKey::ByName("dvar".to_string())) + .or_else(|| matches.get(&CaptureKey::ByName("pvar".to_string()))) .map(|s| s.as_str()) .unwrap_or(""); let path_part = matches |
