rust-lang / rust-lang/glob

Question: what is the correct approach for matching windows paths

Open
#159 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
595
Forks
93
PR merge metrics
No merged PRs in 30d

Description

I want to match the following pattern:
C:\Users\*\path\to\program.exe
I expect it to match with
C:\Users\hedwigz\path\to\program.exe
but shouldn't match with:
C:\Users\hedwigz\another\path\to\program.exe
But feeding this straight to glob pattern does not work as I expected

    fn matches_wildcard(&self, path: &str, wildcard: &str) -> bool {
        if let Ok(pattern) = Pattern::new(wildcard.to_ascii_lowercase().as_str()) {
            pattern.matches(path.to_ascii_lowercase().as_str())
        } else {
            false
        }
    }

What is the correct approach here?
Thanks

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the matches_wildcard function and the Pattern::new call shown in the report, then reproduce both Windows path examples against the glob matcher. Determine how the pattern treats separators and intermediate path components; done means the intended match and non-match behavior is established or the needed change is clearly scoped.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.