MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / wildcard_match

Function wildcard_match

crates/opencode-permission/src/engine.rs:216–237  ·  view source on GitHub ↗
(text: &str, pattern: &str)

Source from the content-addressed store, hash-verified

214}
215
216fn wildcard_match(text: &str, pattern: &str) -> bool {
217 if pattern == "*" {
218 return true;
219 }
220
221 if pattern.starts_with('*') && pattern.ends_with('*') {
222 let middle = &pattern[1..pattern.len() - 1];
223 return text.contains(middle);
224 }
225
226 if pattern.starts_with('*') {
227 let suffix = &pattern[1..];
228 return text.ends_with(suffix);
229 }
230
231 if pattern.ends_with('*') {
232 let prefix = &pattern[..pattern.len() - 1];
233 return text.starts_with(prefix);
234 }
235
236 text == pattern
237}
238
239#[derive(Debug, thiserror::Error)]
240pub enum PermissionError {

Callers 1

coveredMethod · 0.70

Calls 1

containsMethod · 0.80

Tested by

no test coverage detected