mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
Enhance context matching for exclude rules with wildcard support
This commit is contained in:
parent
545aad9eea
commit
2b00cae8e1
1 changed files with 21 additions and 4 deletions
|
|
@ -98,12 +98,29 @@ impl Exclude {
|
|||
return true;
|
||||
}
|
||||
|
||||
// Handle glob patterns
|
||||
// Handle glob patterns with wildcard
|
||||
if self.context.ends_with("/**") {
|
||||
let prefix = &self.context[..self.context.len() - 3];
|
||||
path.starts_with(prefix)
|
||||
} else {
|
||||
path == self.context || path.starts_with(&format!("{}/", self.context))
|
||||
|
||||
// Check if path starts with prefix (absolute path match)
|
||||
if path.starts_with(prefix) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if path contains the pattern anywhere (for relative patterns like "/target/**")
|
||||
// This allows "/target/**" to match "/home/user/project/target/debug"
|
||||
if prefix.starts_with('/') && !prefix.starts_with("//") {
|
||||
// Single leading slash means relative pattern - check if path contains this segment
|
||||
let pattern = &prefix[1..]; // Remove leading slash
|
||||
if path.contains(&format!("/{}/", pattern)) || path.ends_with(&format!("/{}", pattern)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Exact match or prefix match for non-wildcard patterns
|
||||
path == self.context || path.starts_with(&format!("{}/", self.context))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue