Appearance
getFilePathNotQuery 获取无查询参数路径
function getFilePathNotQuery(filePath: string): string
从文件路径中移除查询参数,返回不包含 ? 后内容的文件路径。
参数
| 参数名 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| filePath | 文件路径,可包含查询参数 | string | 必填 |
返回值
| 返回值 | 说明 | 类型 |
|---|---|---|
| path | 不包含查询参数的文件路径;路径无效时返回空字符串 | string |
示例
typescript
import { getFilePathNotQuery } from '@mingto/tools'
getFilePathNotQuery('/docs/report.pdf?download=1') // '/docs/report.pdf'
getFilePathNotQuery('/docs/report.pdf') // '/docs/report.pdf'
getFilePathNotQuery('/api/users') // ''