getFileExtension

View sourcegetFileExtension(url: string): string

Returns the final dot-delimited segment of a string.

This helper does not isolate a path segment before looking for a dot. If the input contains no dot, it returns the entire input; if it ends in a dot, it returns an empty string. Query strings and backslashes are treated as normal characters.

Examples

getFileExtension('/assets/hero.sprite.png') // 'png'
getFileExtension('README') // 'README'

Parameters

NameDescriptionDefault
url

Path-like string to inspect.

—

Returns

The text after the final dot, or the input when no dot is present.