Fix bug with regex matching active navi link for mobile and style mobile active navi link

This commit is contained in:
kitajchuk committed 2021-06-17 18:23:15 -07:00
1 parent 6a54e2088c
commit d269a63d48
2 files changed
+20 -6

No files matched your search

+4 -2
View File
@@ -9,10 +9,12 @@ import { Button, Icon, useMobileMedia } from './jambonz-ui';
function NaviItem({obj}) {
const router = useRouter();
const regex = new RegExp(`^${obj.link}`);
const rSlash = /^\/|\/$/g;
const cleanLink = obj.link.replace(rSlash, '');
const cleanPath = router.asPath.replace(rSlash, '');
const classes = {
navi__link: true,
active: regex.test(router.asPath),
active: cleanLink === cleanPath,
};
return (