pub fn normalize_dir(v: &str) -> String
Expand description
Modified from the opendal::raw::normalize_root
§The different
It doesn’t always append /
ahead of the path,
It only keeps /
ahead if the original path starts with /
.
Make sure the directory is normalized to style like abc/def/
.
§Normalize Rules
- All whitespace will be trimmed:
abc/def
=>abc/def
- All leading / will be trimmed:
///abc
=>abc
- Internal // will be replaced by /:
abc///def
=>abc/def
- Empty path will be
/
: `` =>/
- (Removed❗️)
Add leading/
if not starts with:abc/
=>/abc/
- Add trailing
/
if not ends with:/abc
=>/abc/
Finally, we will got path like /path/to/root/
.