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.

Assessment

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

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.

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

Dominant language
Rust
Stars
597
Forks
97
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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.

More from rust-lang/glob

All issues in rust-lang/glob

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.