JS: Skip link when "href" attribute is not present

Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
Juraj Oravec 2022-06-20 00:08:09 +02:00
parent 314b3d56f2
commit 26051543fd
Signed by: SGOrava
GPG Key ID: 13660A3F1D9F093B

View File

@ -25,18 +25,20 @@ for (link of links) {
linkTitle = siteTitle; linkTitle = siteTitle;
} }
if (link.getAttribute('href').startsWith('/')) { if (link.hasAttribute('href') == true) {
linkUrl = window.location.protocol + '//' + window.location.hostname + link.getAttribute('href'); if (link.getAttribute('href').startsWith('/')) {
} else if (!link.getAttribute('href').includes('/')) { linkUrl = window.location.protocol + '//' + window.location.hostname + link.getAttribute('href');
linkUrl = window.location.protocol + '//' + window.location.hostname + '/' + link.getAttribute('href'); } else if (!link.getAttribute('href').includes('/')) {
} else { linkUrl = window.location.protocol + '//' + window.location.hostname + '/' + link.getAttribute('href');
linkUrl = link.getAttribute('href'); } else {
} linkUrl = link.getAttribute('href');
}
availableLinks.push({ availableLinks.push({
title: linkTitle, title: linkTitle,
url: linkUrl url: linkUrl
}); });
}
} }
} }