Appearance
getFileQuery 获取文件查询参数
function getFileQuery(filePath: string): Record<string, any>
从文件路径中提取查询参数并转换为对象。路径中没有查询参数时返回空对象。
参数
| 参数名 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| filePath | 文件路径,可包含查询参数 | string | 必填 |
返回值
| 返回值 | 说明 | 类型 |
|---|---|---|
| query | 查询参数对象 | Record<string, any> |
示例
typescript
import { getFileQuery } from '@mingto/tools'
getFileQuery('/docs/report.pdf?download=1&name=test')
// { download: '1', name: 'test' }
getFileQuery('/docs/report.pdf')
// {}