Skip to content

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