Perform glob-style pattern matching Supports: - `*` matches any sequence of characters (except /) - `**` matches any sequence including / - `:*` at the end matches any suffix (including empty)
(&self, pattern: &str, text: &str)
| 182 | /// - `**` matches any sequence including / |
| 183 | /// - `:*` at the end matches any suffix (including empty) |
| 184 | fn glob_match(&self, pattern: &str, text: &str) -> bool { |
| 185 | // Handle special `:*` suffix (matches any args after the prefix) |
| 186 | if let Some(prefix) = pattern.strip_suffix(":*") { |
| 187 | return text.starts_with(prefix); |
| 188 | } |
| 189 | |
| 190 | // Normalize Windows backslashes to forward slashes for consistent matching |
| 191 | let text = text.replace('\\', "/"); |
| 192 | |
| 193 | // Convert glob pattern to regex pattern |
| 194 | let regex_pattern = Self::glob_to_regex(pattern); |
| 195 | if let Ok(re) = regex::Regex::new(®ex_pattern) { |
| 196 | re.is_match(&text) |
| 197 | } else { |
| 198 | // Fallback to simple prefix match if regex fails |
| 199 | text.starts_with(pattern) |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | /// Convert glob pattern to regex pattern |
| 204 | fn glob_to_regex(pattern: &str) -> String { |
no outgoing calls
no test coverage detected