Skip to content

Commit

Permalink
fix(language_redirect): ensure siteURL ends with a slash before redir…
Browse files Browse the repository at this point in the history
…ecting
  • Loading branch information
entelecheia committed Jul 9, 2024
1 parent 133fe42 commit 8709c13
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion book/_addons/language_redirect.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
var userLang = navigator.language || navigator.userLanguage;
var langPrefix = userLang.split("-")[0];
var supportedLangs = ["en", "ko"];
var siteURL = window.location.href.split('/index.html')[0] + '/';
var siteURL = window.location.href.split('/index.html')[0];
if (!siteURL.endsWith('/')) {
siteURL += '/';
}
var targetLang = supportedLangs.includes(langPrefix) ? langPrefix : "en";
window.location.replace(siteURL + targetLang + "/index.html");
</script>
Expand All @@ -16,3 +19,6 @@
<p>Redirecting to the appropriate language...</p>
</body>
</html>

</body>
</html>

0 comments on commit 8709c13

Please sign in to comment.