ray-template/packages/utils/src/equal-router-path.ts
XiaoDaiGua-Ray 403fdd589a feat!: rebuild Ray Template as a monorepo
Share workspace packages between Ray Admin and the interactive docs.

BREAKING CHANGE: v6 is a new major line. v5 stays on legacy/v5.
2026-11-04 14:01:28 +08:00

15 lines
374 B
TypeScript

/**
*
* @param path1 第一个路由路径
* @param path2 第二个路由路径
*
* @description
* 比较路径,忽略查询参数、片段和末尾斜杠。
*/
export const equalRouterPath = (path1: string, path2: string) => {
const normalize = (path: string) =>
path.split(/[?#]/, 1)[0].replace(/\/+$/, '')
return normalize(path1) === normalize(path2)
}