diff options
-rw-r--r-- | src/htmx.js | 2 | ||||
-rw-r--r-- | test/attributes/hx-boost.js | 26 |
2 files changed, 27 insertions, 1 deletions
diff --git a/src/htmx.js b/src/htmx.js index f949da04..911b7dde 100644 --- a/src/htmx.js +++ b/src/htmx.js @@ -2323,7 +2323,7 @@ var htmx = (function() { const rawAttribute = getRawAttribute(elt, 'method') verb = (/** @type HttpVerb */(rawAttribute ? rawAttribute.toLowerCase() : 'get')) path = getRawAttribute(elt, 'action') - if (verb === 'get' && path.includes('?')) { + if (verb === 'get' && path && path.includes('?')) { path = path.replace(/\?[^#]+/, '') } } diff --git a/test/attributes/hx-boost.js b/test/attributes/hx-boost.js index 20b49f63..2b1928f3 100644 --- a/test/attributes/hx-boost.js +++ b/test/attributes/hx-boost.js @@ -143,4 +143,30 @@ describe('hx-boost attribute', function() { this.server.respond() div.innerHTML.should.equal('Boosted!') }) + + it('form get with an unset action property', function() { + this.server.respondWith('GET', /\/*/, function(xhr) { + should.equal(undefined, getParameters(xhr).foo) + xhr.respond(200, {}, 'Boosted!') + }) + + var div = make('<div hx-target="this" hx-boost="true"><form id="f1" method="get"><button id="b1">Submit</button></form></div>') + var btn = byId('b1') + btn.click() + this.server.respond() + div.innerHTML.should.equal('Boosted!') + }) + + it('form get with an empty action property', function() { + this.server.respondWith('GET', /\/*/, function(xhr) { + should.equal(undefined, getParameters(xhr).foo) + xhr.respond(200, {}, 'Boosted!') + }) + + var div = make('<div hx-target="this" hx-boost="true"><form id="f1" action="" method="get"><button id="b1">Submit</button></form></div>') + var btn = byId('b1') + btn.click() + this.server.respond() + div.innerHTML.should.equal('Boosted!') + }) }) |