gitlab_monitor/utils/pathTools.ts
zhaoyingbo 012fa97e8b
All checks were successful
CI Monitor MIflow / build-image (push) Successful in 36s
feat: 修改路由判断方式 & 增加入口路由打印
2024-07-30 09:29:45 +00:00

12 lines
371 B
TypeScript

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