File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,19 +24,20 @@ export const Menu = ({ headerMenu }: Props) => {
2424
2525 const isActive = ( path : string | string [ ] , full = false ) => {
2626 const currentPath = location . pathname ;
27+ const paths = Array . isArray ( path ) ? path : [ path ] ;
2728
28- if ( Array . isArray ( path ) ) {
29- return path . some ( ( p ) => ( full ? p === currentPath : currentPath === p || currentPath . startsWith ( p + '/' ) ) ) ;
30- }
29+ return paths . some ( ( p ) => {
30+ if ( currentPath === p ) {
31+ return true ;
32+ }
3133
32- if ( full ) {
33- return path === currentPath ;
34- }
34+ if ( full ) {
35+ return false ;
36+ }
3537
36- return (
37- currentPath === path ||
38- ( currentPath . startsWith ( path ) && ( currentPath [ path . length ] === '/' || path . endsWith ( '/' ) ) )
39- ) ;
38+ const normalizedPath = p . endsWith ( '/' ) ? p : p + '/' ;
39+ return currentPath . startsWith ( normalizedPath ) ;
40+ } ) ;
4041 } ;
4142
4243 return (
You can’t perform that action at this time.
0 commit comments