MCPcopy Create free account
hub / github.com/angular/angular / normalize_path

Function normalize_path

packages/compiler-cli/preprocessor/ng-analyze/src/fs.rs:80–95  ·  view source on GitHub ↗

Normalize a path for lookup (resolve . and .., remove trailing slashes) Performs case-folding on case-insensitive platforms (Windows/macOS) to match real FS behavior.

(path: &'a Path)

Source from the content-addressed store, hash-verified

78///
79/// Performs case-folding on case-insensitive platforms (Windows/macOS) to match real FS behavior.
80pub fn normalize_path<'a>(path: &'a Path) -> std::borrow::Cow<'a, Path> {
81 let normalized = normalize_path_structural(path);
82
83 let needs_case_fold = cfg!(any(target_os = "windows", target_os = "macos"))
84 && normalized
85 .to_str()
86 .map(|s| s.chars().any(|c| c.is_uppercase()))
87 .unwrap_or(true);
88
89 if !needs_case_fold {
90 return normalized;
91 }
92
93 let path_str = normalized.to_string_lossy().to_lowercase();
94 std::borrow::Cow::Owned(PathBuf::from(path_str))
95}
96
97pub fn normalize_path_structural<'a>(path: &'a Path) -> std::borrow::Cow<'a, Path> {
98 // Fast path: check if normalization is needed

Callers 15

expand_globsFunction · 0.85
register_templateMethod · 0.85
unregister_ts_fileMethod · 0.85
set_root_dirsMethod · 0.85
remove_virtual_fileMethod · 0.85
is_allowed_uncachedMethod · 0.85
upsert_fileMethod · 0.85
is_virtualMethod · 0.85

Calls 4

mapMethod · 0.80
anyMethod · 0.80
charsMethod · 0.80

Tested by

no test coverage detected