1
0
mirror of https://github.com/osmarks/website synced 2024-12-23 16:40:31 +00:00

Fix bug in prefetch

This commit is contained in:
osmarks 2024-07-23 09:40:02 +01:00
parent 774357e134
commit 5436237317

View File

@ -6,7 +6,11 @@ const prefetchHook = () => {
let lastFetch = 0 let lastFetch = 0
const prefetch = event => { const prefetch = event => {
if (Date.now() - lastFetch >= 200) { if (Date.now() - lastFetch >= 200) {
const href = new URL(event.target.getAttribute("href"), window.location) let target = event.target
while (!target.hasAttribute("href")) {
target = target.parentElement
}
const href = new URL(target.getAttribute("href"), window.location)
if (href.origin === window.location.origin) { if (href.origin === window.location.origin) {
for (const ignorePath of ignorePaths) { for (const ignorePath of ignorePaths) {
if (href.pathname.startsWith(ignorePath)) return if (href.pathname.startsWith(ignorePath)) return