JS: Skip link when "href" attribute is not present
Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
parent
314b3d56f2
commit
26051543fd
@ -25,18 +25,20 @@ for (link of links) {
|
||||
linkTitle = siteTitle;
|
||||
}
|
||||
|
||||
if (link.getAttribute('href').startsWith('/')) {
|
||||
linkUrl = window.location.protocol + '//' + window.location.hostname + link.getAttribute('href');
|
||||
} else if (!link.getAttribute('href').includes('/')) {
|
||||
linkUrl = window.location.protocol + '//' + window.location.hostname + '/' + link.getAttribute('href');
|
||||
} else {
|
||||
linkUrl = link.getAttribute('href');
|
||||
}
|
||||
if (link.hasAttribute('href') == true) {
|
||||
if (link.getAttribute('href').startsWith('/')) {
|
||||
linkUrl = window.location.protocol + '//' + window.location.hostname + link.getAttribute('href');
|
||||
} else if (!link.getAttribute('href').includes('/')) {
|
||||
linkUrl = window.location.protocol + '//' + window.location.hostname + '/' + link.getAttribute('href');
|
||||
} else {
|
||||
linkUrl = link.getAttribute('href');
|
||||
}
|
||||
|
||||
availableLinks.push({
|
||||
title: linkTitle,
|
||||
url: linkUrl
|
||||
});
|
||||
availableLinks.push({
|
||||
title: linkTitle,
|
||||
url: linkUrl
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user