mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-13 21:01:21 +08:00
Co-authored-by: Konsti Wohlwend <n2d4xc@gmail.com> Co-authored-by: Madison Kennedy <madison@Madisons-MacBook-Pro.local> Co-authored-by: BilalG1 <bg2002@gmail.com>
11 lines
280 B
TypeScript
11 lines
280 B
TypeScript
export function isActive(
|
|
url: string,
|
|
pathname: string,
|
|
nested = true,
|
|
): boolean {
|
|
if (url.endsWith('/')) url = url.slice(0, -1);
|
|
if (pathname.endsWith('/')) pathname = pathname.slice(0, -1);
|
|
|
|
return url === pathname || (nested && pathname.startsWith(`${url}/`));
|
|
}
|