Appearance
getFileName 获取文件名
function getFileName(filePath: string): string
从文件路径中提取完整文件名,包含后缀。路径无效或不匹配支持的文件后缀时返回空字符串或仅标题。
参数
| 参数名 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| filePath | 文件路径,可包含查询参数 | string | 必填 |
返回值
| 返回值 | 说明 | 类型 |
|---|---|---|
| fileName | 包含后缀的文件名 | string |
示例
typescript
import { getFileName } from '@mingto/tools'
getFileName('/docs/report.pdf') // 'report.pdf'
getFileName('/docs/report.pdf?download=1') // 'report.pdf'
getFileName('/api/users') // ''