File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -58,12 +58,11 @@ export const BaseLink = forwardRef(function Link(
58
58
ref
59
59
) {
60
60
const { asPath } = useRouter ( )
61
- const cleanAsPath = asPath . replace ( / # .* / , "" ) ;
62
61
const { flipForRtl } = useRtlFlip ( )
63
62
64
63
let href = ( to ?? hrefProp ) as string
65
64
66
- const isActive = url . isHrefActive ( href , cleanAsPath , isPartiallyActive )
65
+ const isActive = url . isHrefActive ( href , asPath , isPartiallyActive )
67
66
const isDiscordInvite = url . isDiscordInvite ( href )
68
67
const isPdf = url . isPdf ( href )
69
68
const isExternal = url . isExternal ( href )
Original file line number Diff line number Diff line change @@ -28,17 +28,18 @@ export const sanitizeHitUrl = (url: string): string =>
28
28
. replace ( "#content" , "" )
29
29
. replace ( "#top" , "" )
30
30
31
+ // remove any query params or hashes from the path
32
+ export const cleanPath = ( path : string ) : string => path . replace ( / [ $ # ] .+ $ / , "" )
33
+
31
34
export const isHrefActive = (
32
35
href : string ,
33
36
pathname : string ,
34
37
isPartiallyActive ?: boolean
35
- ) => ( isPartiallyActive ? pathname . startsWith ( href ) : pathname === href )
38
+ ) =>
39
+ isPartiallyActive ? pathname . startsWith ( href ) : cleanPath ( pathname ) === href
36
40
37
41
export const isHash = ( href : string ) : boolean => href . startsWith ( "#" )
38
42
39
- // remove any query params or hashes from the path
40
- export const cleanPath = ( path : string ) : string => path . replace ( / [ $ # ] .+ $ / , "" )
41
-
42
43
export const addSlashes = ( href : string ) : string => {
43
44
if ( isExternal ( href ) ) return href
44
45
return join ( "/" , href , "/" )
You can’t perform that action at this time.
0 commit comments