Function symbolic_common::clean_path[][src]

pub fn clean_path(path: &str) -> Cow<'_, str>

Simplifies paths by stripping redundant components.

This removes redundant ../ or ./ path components. However, this function does not operate on the file system. Since it does not resolve symlinks, this is a potentially lossy operation.

Examples

Remove ./ components:

assert_eq!(symbolic_common::clean_path("/a/./b"), "/a/b");

Remove path components followed by ../:

assert_eq!(symbolic_common::clean_path("/a/b/../c"), "/a/c");

Note that when the path is relative, the parent dir components may exceed the top-level:

assert_eq!(symbolic_common::clean_path("/foo/../../b"), "../b");