Skip to content

Commit

Permalink
fix: Fixed bug with nav urls including the page source
Browse files Browse the repository at this point in the history
  • Loading branch information
Luna-Klatzer committed Sep 17, 2024
1 parent c0d8517 commit b6e2bc8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/partials/header-nav-bar.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ const pages = {
function changeHrefLocaleIfNecessary(links) {
const localeName = localStorage.getItem(window.localeKey);
for (const link of links) {
// Insert locale name into the URL
const href = link.getAttribute("href");
// Insert locale name into the URL and replace the domain if it's included in the URL
const href = link
.getAttribute("href")
.replace(window.location.origin, "")
.replace(`${window.location.protocol}//`, "");
if (!href.includes(localeName) && !href.includes("docs")) {
link.setAttribute("href", `/${localeName}${href}`);
}
Expand Down

0 comments on commit b6e2bc8

Please sign in to comment.