Optional
config: number | NormalizePathConfigimport { assertEquals } from "jsr:@std/assert"
// aliasing our functions for brevity
const eq = assertEquals, fn = normalizePath
eq(fn("../a/./b/../././/c.txt"), "../a//c.txt")
eq(fn("./.\\.\\a\\b\\.././.\\.///c.txt"), "./a///c.txt")
eq(fn("/home\\.config/a\\..\\...\\b\\./c.txt"), "/home/.config/.../b/c.txt")
eq(fn("file:///./././a\\b/..\\././.\\c.txt"), "file:///a/c.txt")
normalize a path by reducing and removing redundant dot-slash ("./", "../", ".\", and "..\") path navigators from a path. the returned output is always a posix-style path.
to read about the optional
config
parameter, refer to the docs of normalizePosixPath, which is the underlying function that takes care most of the normalization.