Hide content by Regex pattern instead of Wildcard pattern
Closed this issue · 1 comments
Specific Demand
Hi!
Wildcards has very limited capabilities so would be useful to use regex patterns instead.
Unfortunately I extreamly novice in Rust lang and not a professional programmer at all, don't know how to suggest patches to project, but after "cargo add regex" my implementation builds good and server works and filters patterns as expected.
And may be you can help me in one specific problem -- how to prevent listing of root of server, but keep list files in subfolders?
Implement Suggestion
replace in utils.rs
pub fn glob(pattern: &str, target: &str) -> bool {
let pat = match ::glob::Pattern::new(pattern) {
Ok(pat) => pat,
Err(_) => return false,
};
pat.matches(target)
}
to
pub fn glob(pattern: &str, target: &str) -> bool {
let rex = match ::regex::Regex::new(pattern) {
Ok(rex) => rex,
Err(_) => return false,
};
rex.is_match(target)
}
We will not support this feature.
Glob patterns are more mature for matching paths, which explains why they are widely used in ignore files.
Furthermore, tens of thousands of users are already accustomed to using globs as the value of hidden
. You can't just change that on a whim.