Skip to content

[F] getNormalizedPathComponents

function getNormalizedPathComponents(path, currentDirectory): string[]

Parse a path into an array containing a root component (at index 0) and zero or more path components (at indices > 0). The result is normalized. If the path is relative, the root component is "". If the path is absolute, the root component includes the first path separator (/).

getNormalizedPathComponents("to/dir/../file.ext", "/path/") === ["/", "path", "to", "file.ext"]

Parameters

ParameterType
pathstring
currentDirectoryundefined | string

Returns

string[]