File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed 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