| Crates.io | path_normalizer |
| lib.rs | path_normalizer |
| version | 0.1.1 |
| created_at | 2025-08-24 12:29:34.089516+00 |
| updated_at | 2025-08-24 13:54:42.510872+00 |
| description | Lexically normalize paths in Rust without touching the filesystem. |
| homepage | https://github.com/pjdur/path_normalizer |
| repository | https://github.com/pjdur/path_normalizer |
| max_upload_size | |
| id | 1808295 |
| size | 9,768 |
๐งน A lightweight Rust crate for lexically normalizing paths โ no filesystem access required.
This crate is useful for scenarios where you need to manipulate or validate paths without relying on the filesystem. It's particularly handy for:
Note: The features of this crate exist in the Rust standard libary (
std), but only on the nightly toolchain. This crate provides its features but available regardless of Rust toolchain.
"foo/./bar/../baz" to "foo/baz"Add this to your Cargo.toml:
[dependencies]
path_normalizer = "0.1"
use path_normalizer::PathNormalizeExt;
use std::path::Path;
fn main() {
let path = Path::new("foo/./bar/../baz");
let normalized = path.normalize_path().unwrap();
println!("Normalized: {}", normalized.display()); // Outputs: foo/baz
}
Unlike canonicalize(), this crate doesn't resolve symlinks or check the filesystem. It simply rewrites the path using lexical rules โ making it ideal for virtual paths, config parsing, or sandboxed environments.
MIT
Made with โค๏ธ for Rustaceans who like their paths tidy.