Skip to content

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')
// {}