Skip to content

fix ​

The fix() function cleans a POSIX path by removing a trailing slash and a leading ./ prefix.

WARNING

Works only with POSIX paths (not Windows paths).

Interactive example ​

Syntax ​

typescript
function fix(
	path: string
): string;

Parameters ​

  • path : The path to clean.

Return value ​

The path without a trailing slash and without a leading ./ prefix. If the path is /, the result is an empty string.

See also ​

Released under the MIT license.