Skip to main content

normalize_glob_pattern

Function normalize_glob_pattern 

Source
pub fn normalize_glob_pattern(pattern: &str) -> String
Expand description

Normalize a glob pattern so it matches the way indexed paths are stored.

Indexed paths are stored relative and without a ./ prefix (e.g. src/parsers/rust.rs) — see the strip_prefix("./") normalization applied throughout query::mod. A relative glob such as src/** must therefore be anchored so it can match those bare paths. We prepend **/ (not ./): ./src/** fails to match src/parsers/rust.rs because of the leading ./, whereas **/src/** matches it. This mirrors the convention the integration tests already rely on and is forgiving of LLM-authored patterns that omit a leading **/ (REF-191).

Examples:

  • “src//*.rs” → “/src/**/*.rs”
  • “main.rs” → “**/main.rs”
  • “./services/**/*.php” → unchanged (already anchored)
  • “/abs/path” → unchanged (absolute)
  • “**/foo” → unchanged (already prefixed)