Skip to main content

normalize_pattern_for_base

Function normalize_pattern_for_base 

Source
pub fn normalize_pattern_for_base(pattern: &str, base: Option<&Path>) -> String
Expand description

Normalize a config path pattern for matching against paths discovered under base: expand a leading ~, then rewrite an absolute pattern as one relative to base when base contains it.

The rewrite is what makes an absolute pattern usable as a walker override: the ignore crate reads a leading / as “anchored to the walk base”, so /home/dev/docs/** would otherwise be understood as <base>/home/dev/docs/** and match nothing. A pattern pointing outside base is left absolute - nothing under this walk can match it, which is the correct outcome.