chipsenkbeil / typed-path

Provides typed variants of Path and PathBuf for Unix and Windows
39 stars 7 forks source link

Feat/add normalize function #9

Closed chipsenkbeil closed 1 year ago

chipsenkbeil commented 1 year ago

Adds a new normalize method to both Path and Utf8Path alongside is_parent and is_current methods on Component and Utf8Component traits.

The normalize method will resolve . and .. with .. being removed if the path is relative and there is nothing else to resolve.

This can potentially be used to address #8 by determining if an existing path is relative and - if so - prepending the current working directory as a path and then normalizing it. The trick is figuring out how to take a platform-specific path and convert it to the proper encoding, or just not caring about that.