getUrlFilename
Extract the filename from a URL pathname, optionally including the extension, so downloads and asset labels are simple to derive.
Usage
getUrlFilename extracts the filename from a URL.
import { getUrlFilename } from '@movk/core'
getUrlFilename('https://example.com/path/file.pdf') // 'file.pdf'
getUrlFilename('https://example.com/path/file.pdf', false) // 'file'
getUrlFilename('https://example.com/path/') // ''
API
getUrlFilename(url, includeExtension?)
Get the filename from a URL.
Parameters
url
string required
The URL string.
includeExtension
boolean
Whether to include the file extension. Defaults to
true.Returns
returns
string
The filename.
Changelog
No recent changes