File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -2316,9 +2316,10 @@ var htmx = (function() {
23162316 } else {
23172317 const rawAttribute = getRawAttribute ( elt , 'method' )
23182318 verb = ( /** @type HttpVerb */ ( rawAttribute ? rawAttribute . toLowerCase ( ) : 'get' ) )
2319- if ( verb === 'get' ) {
2320- }
23212319 path = getRawAttribute ( elt , 'action' )
2320+ if ( verb === 'get' && path . includes ( '?' ) ) {
2321+ path = path . replace ( / \? [ ^ # ] + / , '' )
2322+ }
23222323 }
23232324 triggerSpecs . forEach ( function ( triggerSpec ) {
23242325 addEventListener ( elt , function ( node , evt ) {
Original file line number Diff line number Diff line change @@ -118,4 +118,29 @@ describe('hx-boost attribute', function() {
118118 this . server . respond ( )
119119 btn . innerHTML . should . equal ( 'Boosted!' )
120120 } )
121+
122+ it ( 'form get w/ search params in action property excludes search params' , function ( ) {
123+ this . server . respondWith ( 'GET' , / \/ t e s t .* / , function ( xhr ) {
124+ should . equal ( undefined , getParameters ( xhr ) . foo )
125+ xhr . respond ( 200 , { } , 'Boosted!' )
126+ } )
127+
128+ var div = make ( '<div hx-target="this" hx-boost="true"><form id="f1" action="/test?foo=bar" method="get"><button id="b1">Submit</button></form></div>' )
129+ var btn = byId ( 'b1' )
130+ btn . click ( )
131+ this . server . respond ( )
132+ div . innerHTML . should . equal ( 'Boosted!' )
133+ } )
134+
135+ it ( 'form post w/ query params in action property uses full url' , function ( ) {
136+ this . server . respondWith ( 'POST' , / \/ t e s t .* / , function ( xhr ) {
137+ should . equal ( undefined , getParameters ( xhr ) . foo )
138+ xhr . respond ( 200 , { } , 'Boosted!' )
139+ } )
140+ var div = make ( '<div hx-target="this" hx-boost="true"><form id="f1" action="/test?foo=bar" method="post"><button id="b1">Submit</button></form></div>' )
141+ var btn = byId ( 'b1' )
142+ btn . click ( )
143+ this . server . respond ( )
144+ div . innerHTML . should . equal ( 'Boosted!' )
145+ } )
121146} )
You can’t perform that action at this time.
0 commit comments