This commit is contained in:
parent
091fcb2aed
commit
cc84b59f78
@ -1,9 +1,12 @@
|
|||||||
export const makeCheckPathTool = (url: string, prefix?: string) => {
|
export const makeCheckPathTool = (url: string, prefix?: string) => {
|
||||||
const { pathname } = new URL(url)
|
const { pathname } = new URL(url)
|
||||||
|
const makePath = (path: string) => `${prefix || ""}${path}`
|
||||||
return {
|
return {
|
||||||
// 精确匹配
|
// 精确匹配
|
||||||
exactCheck: (path: string) => pathname === `${prefix}${path}`,
|
exactCheck: (path: string) => {
|
||||||
|
return pathname === makePath(path)
|
||||||
|
},
|
||||||
// 前缀匹配
|
// 前缀匹配
|
||||||
startsWithCheck: (path: string) => pathname.startsWith(`${prefix}${path}`),
|
startsWithCheck: (path: string) => pathname.startsWith(makePath(path)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user