path_normalizer 0.1.1

Lexically normalize paths in Rust without touching the filesystem.
Documentation
  • Coverage
  • 80%
    4 out of 5 items documented0 out of 3 items with examples
  • Size
  • Source code size: 9.76 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 313.13 kB This is the summed size of all files generated by rustdoc for all configured targets
  • ร˜ build duration
  • this release: 4s Average build duration of successful builds.
  • all releases: 4s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Pjdur/path_normalizer
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Pjdur

path_normalizer

Crates.io Docs.rs CI License: MIT

๐Ÿงน A lightweight Rust crate for lexically normalizing paths โ€” no filesystem access required.

Why?

This crate is useful for scenarios where you need to manipulate or validate paths without relying on the filesystem. It's particularly handy for:

  • Virtual Filesystems: When working with in-memory or virtual filesystems, you can't rely on actual paths existing on disk.
  • Configuration Parsing: When reading configuration files, you may need to normalize paths specified by users.
  • Sandboxed Environments: In environments where filesystem access is restricted, you can still perform path manipulations.

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.

โœจ Features

  • Normalize paths like "foo/./bar/../baz" to "foo/baz"
  • Works purely on string logic โ€” doesn't touch the filesystem
  • Cross-platform and fast

๐Ÿ“ฆ Installation

Add this to your Cargo.toml:

[dependencies]

path_normalizer = "0.1"

๐Ÿš€ Usage

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
}

๐Ÿ”’ Why Lexical?

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.

๐Ÿ“š License

MIT


Made with โค๏ธ for Rustaceans who like their paths tidy.