[GH-ISSUE #410] Hide content by Regex pattern instead of Wildcard pattern #221

Closed
opened 2026-04-08 16:51:15 +03:00 by zhus · 1 comment
Owner

Originally created by @zhus on GitHub (Jul 4, 2024).
Original GitHub issue: https://github.com/sigoden/dufs/issues/410

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)
}
Originally created by @zhus on GitHub (Jul 4, 2024). Original GitHub issue: https://github.com/sigoden/dufs/issues/410 ## 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) } ```
zhus closed this issue 2026-04-08 16:51:15 +03:00
Author
Owner

@sigoden commented on GitHub (Jul 4, 2024):

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.

<!-- gh-comment-id:2208683519 --> @sigoden commented on GitHub (Jul 4, 2024): 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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sigoden/dufs#221