Use raw attribute href on hx-boost (#1742)

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.
This commit is contained in:
Alexander Petros 2023-09-06 11:54:43 -04:00 committed by GitHub
parent d8f7afe5c4
commit 1763cfc64e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -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";

View File

@ -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);