// Dynamic logo link without regex
document.addEventListener('click', function (e) {
var logoLink = e.target.closest('.gm-logo a');
if (!logoLink) {
return;
}
e.preventDefault();
var origin = window.location.origin;
var path = window.location.pathname;
if (path.length > 0 && path.charAt(0) === '/') {
path = path.substring(1);
}
if (path.length > 0 && path.charAt(path.length - 1) === '/') {
path = path.substring(0, path.length - 1);
}
var parts = path.split('/');
var firstSegment = parts[0];
var localizedLangs = ['en', 'pl', 'ru'];
var homepage;
if (localizedLangs.indexOf(firstSegment) !== -1) {
homepage = origin + '/' + firstSegment + '/';
} else {
homepage = origin + '/';
}
window.location.href = homepage;
});
Перейти до вмісту