Skip to content

Commit f552119

Browse files
committed
review fix
1 parent 4a6c8ab commit f552119

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

client_v2/src/common/ui/Menu/Menu.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff 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 (

0 commit comments

Comments
 (0)