Path.normalize

Path normalize() const @safe

Returns a normalized version of this path where redundant separators are collapsed and dot-segments (`.` and `..`) are simplified in a platform-appropriate way.

Normalization rules:

  • Collapses `.` and `..` where possible according to std.path.buildNormalizedPath.
  • Unifies separators to the platform default (`/` on POSIX, `\\` on Windows).
  • Removes redundant trailing separators so that "/a/b/" and "/a/b"

normalize to the same string. The only exceptions are pure roots/anchors (e.g., `"/"`, `"\\"`, "C:\\", "\\\\server\\share\\"), which are preserved.

Notes:

  • This is a pure string-level transformation; it does not access the

filesystem and makes no guarantees about symlinks. Use resolve() for symlink-aware canonicalization.

  • Windows: Paths using the extended-length prefixes (`\\?\\` and

\\?\\UNC\\) are preserved exactly (normalization is skipped) to avoid altering device/extended namespace semantics.

Returns

A new Path representing the normalized path.