gitlab_monitor/utils/pathTools.ts
zhaoyingbo cc84b59f78
All checks were successful
CI Monitor MIflow / build-image (push) Successful in 37s
fix: 修复路径匹配失败
2024-07-30 09:49:31 +00:00

13 lines
384 B
TypeScript

export const makeCheckPathTool = (url: string, prefix?: string) => {
const { pathname } = new URL(url)
const makePath = (path: string) => `${prefix || ""}${path}`
return {
// 精确匹配
exactCheck: (path: string) => {
return pathname === makePath(path)
},
// 前缀匹配
startsWithCheck: (path: string) => pathname.startsWith(makePath(path)),
}
}