Skip to main content

normalize_path

Function normalize_path 

Source
pub fn normalize_path(path: &Path) -> String
Expand description

Lexically normalize a path by resolving . and .. components without hitting the filesystem.

This collapses . / .. segments but only clamps at the filesystem root (/); it is unaware of any environment root, so on its own it does not confine a path to an allowed directory — /workspace/../../etc still normalizes to /etc. Use resolve_within_root to clamp to an environment root, and resolve_within_root_secure when symlinks must also be defeated. Unlike std::fs::canonicalize, this does not require the path to exist and does not follow symlinks.