From 8e28beb0a9ef344aba33b976b8d6fc32620041f2 Mon Sep 17 00:00:00 2001 From: Alexander Petros Date: Tue, 29 Aug 2023 11:20:12 -0400 Subject: [PATCH] Use raw attribute href on hx-boost This resolves a bug when file system URLs are used on Windows. It reverts part of a previous change where URLs were normalized prior to the request in order to reduce key collisions in the history cache. Because htmx's history cache is based entirely on response URLs, not request URLs, I am reasonably confident that reverting this line doesn't affect that optimization at all, but in any case it causes a bug which is more important. --- src/htmx.js | 2 +- test/attributes/hx-disinherit.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/htmx.js b/src/htmx.js index 4c7206a8c..0042680b3 100644 --- a/src/htmx.js +++ b/src/htmx.js @@ -1348,7 +1348,7 @@ return (function () { var verb, path; if (elt.tagName === "A") { verb = "get"; - path = elt.href; // DOM property gives the fully resolved href of a relative link + path = getRawAttribute(elt, 'href') } else { var rawAttribute = getRawAttribute(elt, "method"); verb = rawAttribute ? rawAttribute.toLowerCase() : "get"; diff --git a/test/attributes/hx-disinherit.js b/test/attributes/hx-disinherit.js index f069a8335..f572a5e43 100644 --- a/test/attributes/hx-disinherit.js +++ b/test/attributes/hx-disinherit.js @@ -101,7 +101,7 @@ describe("hx-disinherit attribute", function() { var link = byId("a1"); link.click(); // should match the fully resolved href of the boosted element - should.equal(request.detail.requestConfig.path, request.detail.elt.href); + should.equal(request.detail.requestConfig.path, '/test'); should.equal(request.detail.elt["htmx-internal-data"].boosted, true); } finally { htmx.off("htmx:beforeRequest", handler);