fix(Navbar): fix trailing slash inconsistence between environments

This commit is contained in:
Alexander Navarro 2024-03-19 09:06:15 -03:00
parent 66d337255c
commit b97413e816

View file

@ -52,12 +52,22 @@ const links = [
</div>
<script>
const normilizeUrl = (url: string): string => {
let newUrl = `${url}`;
if (newUrl.endsWith('/')) {
newUrl = newUrl.slice(0, -1);
}
return newUrl;
};
const setActiveLink = () => {
const links =
document.querySelectorAll<HTMLAnchorElement>(`#main-navbar a`);
links.forEach((link) =>
link.pathname === location.pathname
normilizeUrl(link.pathname) === normilizeUrl(location.pathname)
? link.classList.add('active')
: link.classList.remove('active'),
);