fix(links): better http/s handling

This commit is contained in:
SabreCat
2023-04-04 18:25:14 -05:00
parent 7363f08a86
commit 2df6b6461b
2 changed files with 5 additions and 4 deletions

View File

@@ -213,7 +213,7 @@
</a>
<a
class="social-circle"
href="https://twitter.com/habitica"
href="https://twitter.com/habitica/"
target="_blank"
>
<div
@@ -223,7 +223,7 @@
</a>
<a
class="social-circle"
href="https://www.facebook.com/Habitica"
href="https://www.facebook.com/Habitica/"
target="_blank"
>
<div

View File

@@ -8,10 +8,11 @@ export default {
for (let i = 0; i < allLinks.length; i += 1) {
const link = allLinks[i];
const domainIndex = link.href.indexOf('//') + 2;
if ((link.classList.value.indexOf('external-link') === -1)
&& link.href.slice(0, 4) === 'http'
&& !some(TRUSTED_DOMAINS.split(','), domain => link.href.indexOf(domain) === 0)) {
&& domainIndex !== 1
&& !some(TRUSTED_DOMAINS.split(','), domain => link.href.indexOf(domain) === domainIndex)) {
link.classList.add('external-link');
link.addEventListener('click', e => {
if (e.ctrlKey) {