Skip to main content

Module path_normalization

Module path_normalization 

Source
Expand description

Pure functions for cross-platform path normalization

This module provides path normalization utilities for matching coverage data across different platforms and environments. All functions are pure (no I/O) and designed for composition.

§Architecture

Path normalization follows a functional pipeline:

  1. Component extraction - break paths into meaningful segments
  2. Separator normalization - convert all separators to forward slash
  3. Suffix matching - match paths based on meaningful components

§Example

use std::path::Path;
use debtmap::risk::path_normalization::{normalize_path_components, paths_match_by_suffix};

let query = Path::new("src/lib.rs");
let target = Path::new("/home/user/project/src/lib.rs");

let query_components = normalize_path_components(query);
let target_components = normalize_path_components(target);

assert!(paths_match_by_suffix(&query_components, &target_components));

Structs§

NormalizedPath
Result of path normalization with diagnostic info

Enums§

MatchStrategy
Strategy used to match a path

Functions§

find_matching_path
Pure function: Find best matching path from available paths
normalize_path_components
Pure function: Extract meaningful path components
normalize_path_separators
Pure function: Normalize path separators to forward slash
paths_match_by_suffix
Pure function: Check if query path matches target by suffix