Skip to content

Commit 98d8b2d

Browse files
authored
Merge pull request #13331 from 0x0OZ/fix-docs-nav-marker-bug
Fixed broken active link in developer docs navbar [Fixes #10813]
2 parents 8e61036 + 712d3b1 commit 98d8b2d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/lib/utils/url.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,18 @@ export const sanitizeHitUrl = (url: string): string =>
2828
.replace("#content", "")
2929
.replace("#top", "")
3030

31+
// remove any query params or hashes from the path
32+
export const cleanPath = (path: string): string => path.replace(/[$#].+$/, "")
33+
3134
export const isHrefActive = (
3235
href: string,
3336
pathname: string,
3437
isPartiallyActive?: boolean
35-
) => (isPartiallyActive ? pathname.startsWith(href) : pathname === href)
38+
) =>
39+
isPartiallyActive ? pathname.startsWith(href) : cleanPath(pathname) === href
3640

3741
export const isHash = (href: string): boolean => href.startsWith("#")
3842

39-
// remove any query params or hashes from the path
40-
export const cleanPath = (path: string): string => path.replace(/[$#].+$/, "")
41-
4243
export const addSlashes = (href: string): string => {
4344
if (isExternal(href)) return href
4445
return join("/", href, "/")

0 commit comments

Comments
 (0)