Skip to content

[F] removeTrailingDirectorySeparator

function removeTrailingDirectorySeparator(path): string

Removes a trailing directory separator from a path, if it does not already have one.

removeTrailingDirectorySeparator("/path/to/file.ext") === "/path/to/file.ext"
removeTrailingDirectorySeparator("/path/to/file.ext/") === "/path/to/file.ext"

Parameters

ParameterType
pathstring

Returns

string