Appearance
isFilePath 判断文件路径
function isFilePath(filePath: string): boolean
判断字符串是否是支持后缀的文件路径。支持带查询参数的 URL 形式。
参数
| 参数名 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| filePath | 待判断的文件路径 | string | 必填 |
返回值
| 返回值 | 说明 | 类型 |
|---|---|---|
| result | 是支持的文件路径时返回 true,否则返回 false | boolean |
示例
typescript
import { isFilePath } from '@mingto/tools'
isFilePath('https://example.com/report.pdf') // true
isFilePath('/images/avatar.png?x=1') // true
isFilePath('/api/users') // false注意事项
- 支持的后缀来自
FileSuffixEnum。 - 空字符串、
0等被checkEmpty判定为空的值会返回false。