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

10 lines
309 B
TypeScript

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