diff --git a/src/htmx.js b/src/htmx.js index 41ae9b382..16e6af049 100644 --- a/src/htmx.js +++ b/src/htmx.js @@ -2316,9 +2316,10 @@ var htmx = (function() { } else { const rawAttribute = getRawAttribute(elt, 'method') verb = (/** @type HttpVerb */(rawAttribute ? rawAttribute.toLowerCase() : 'get')) - if (verb === 'get') { - } path = getRawAttribute(elt, 'action') + if (verb === 'get' && path.includes('?')) { + path = path.replace(/\?[^#]+/, '') + } } triggerSpecs.forEach(function(triggerSpec) { addEventListener(elt, function(node, evt) { diff --git a/test/attributes/hx-boost.js b/test/attributes/hx-boost.js index e6562e48d..20b49f632 100644 --- a/test/attributes/hx-boost.js +++ b/test/attributes/hx-boost.js @@ -118,4 +118,29 @@ describe('hx-boost attribute', function() { this.server.respond() btn.innerHTML.should.equal('Boosted!') }) + + it('form get w/ search params in action property excludes search params', function() { + this.server.respondWith('GET', /\/test.*/, function(xhr) { + should.equal(undefined, getParameters(xhr).foo) + xhr.respond(200, {}, 'Boosted!') + }) + + var div = make('
') + var btn = byId('b1') + btn.click() + this.server.respond() + div.innerHTML.should.equal('Boosted!') + }) + + it('form post w/ query params in action property uses full url', function() { + this.server.respondWith('POST', /\/test.*/, function(xhr) { + should.equal(undefined, getParameters(xhr).foo) + xhr.respond(200, {}, 'Boosted!') + }) + var div = make('') + var btn = byId('b1') + btn.click() + this.server.respond() + div.innerHTML.should.equal('Boosted!') + }) })