path.posix.normalize
Medium · Paths
Implement normalizePath(path) with exactly the same results as Node's path.posix.normalize(path).
- Repeated slashes become one slash.
- . segments are removed.
- .. removes the previous segment. In an absolute path you cannot go above / (/a/../../b → /b). In a relative path, extra .. segments are kept at the start (../a/../../b → ../../b).
- A trailing slash is kept.
- An empty result becomes . for relative paths (and ./ if the input ended with a slash) and / for absolute ones. "" → ".".
Next: path.posix.join