From 2bc53528d05b42ed146659cfb6214e7e87c2a66a Mon Sep 17 00:00:00 2001 From: Brychan Dempsey Date: Tue, 8 Jun 2021 22:01:11 +1200 Subject: [PATCH] Fixed an issue with link calculation --- RenderHTML.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RenderHTML.html b/RenderHTML.html index bf451cb..291a569 100644 --- a/RenderHTML.html +++ b/RenderHTML.html @@ -11,6 +11,7 @@ const queryString = window.location.search; const queryLoc = window.location.origin; const queryRequest = window.location.href.split('?')[0]; + const windowLoc = window.location.toString(); console.log(queryString); const urlParams = new URLSearchParams(queryString); const requestURL = urlParams.get('url') @@ -38,7 +39,7 @@ // Replace either http:/// or http:// with "" so that: // 1.) links to elements on the same page work // 2.) disable cross-origin requests - var fixedURL = hlinks[i].href.replace(window.location, "").replace(queryLoc, "") + var fixedURL = hlinks[i].href.replace(windowLoc.split('#')[0], "").replace(queryLoc, "") // If the remaining character is the hash, this is a same-page section link if (fixedURL.startsWith("#")) { fixedURL = requestURL + fixedURL;