From 6393226574761cd9c63651afa39015c77c87b68b Mon Sep 17 00:00:00 2001 From: mtmail Date: Wed, 10 Feb 2021 15:04:04 +0100 Subject: [PATCH] link.href is always absolute URL, inspect raw HTML attribute instead (#60) --- src/main.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.js b/src/main.js index a8269c6..8445501 100644 --- a/src/main.js +++ b/src/main.js @@ -25,9 +25,10 @@ document.addEventListener('click', function (e) { // loop parent nodes from the target to the delegation node for (var target = e.target; target && target !== this; target = target.parentNode) { - if (target.matches('a')) { - var target_url = target.href; + if (target.matches('a') && target.href) { + // target.href always contains the full absolute URL, inspect the raw value instead + var target_url = target.attributes.href.value; if (!is_relative_url(target_url)) return; -- 2.39.5