Skip to content

getExtensionName

The getExtensionName() function returns the last extension of a path, without the dot.

WARNING

Works only with POSIX paths (not Windows paths).

Interactive example

Syntax

typescript
function getExtensionName<
	GenericPath extends string
>(
	path: GenericPath
): string | null;

Parameters

  • path : The path to analyze.

Return value

The extension without the dot (e.g. txt) or null when none is found.

See also

Released under the MIT license.