@@ -82,7 +82,7 @@ return (function () {
8282 sock . binaryType = htmx . config . wsBinaryType ;
8383 return sock ;
8484 } ,
85- version : "1.9.0 "
85+ version : "1.9.1 "
8686 } ;
8787
8888 /** @type {import("./htmx").HtmxInternalApi } */
@@ -433,6 +433,23 @@ return (function () {
433433 }
434434 }
435435
436+ function normalizePath ( path ) {
437+ try {
438+ var url = new URL ( path ) ;
439+ if ( url ) {
440+ path = url . pathname + url . search ;
441+ }
442+ // remove trailing slash, unless index page
443+ if ( ! path . match ( '^/$' ) ) {
444+ path = path . replace ( / \/ + $ / , '' ) ;
445+ }
446+ return path ;
447+ } catch ( e ) {
448+ // be kind to IE11, which doesn't support URL()
449+ return path ;
450+ }
451+ }
452+
436453 //==========================================================================================
437454 // public API
438455 //==========================================================================================
@@ -1301,7 +1318,7 @@ return (function () {
13011318 var verb , path ;
13021319 if ( elt . tagName === "A" ) {
13031320 verb = "get" ;
1304- path = getRawAttribute ( elt , ' href' ) ;
1321+ path = elt . href ; // DOM property gives the fully resolved href of a relative link
13051322 } else {
13061323 var rawAttribute = getRawAttribute ( elt , "method" ) ;
13071324 verb = rawAttribute ? rawAttribute . toLowerCase ( ) : "get" ;
@@ -1722,13 +1739,6 @@ return (function () {
17221739 } ) ;
17231740 }
17241741 } ) ;
1725- if ( ! explicitAction && hasAttribute ( elt , 'hx-trigger' ) ) {
1726- explicitAction = true
1727- triggerSpecs . forEach ( function ( triggerSpec ) {
1728- // For "naked" triggers, don't do anything at all
1729- addTriggerHandler ( elt , triggerSpec , nodeData , function ( ) { } )
1730- } )
1731- }
17321742 return explicitAction ;
17331743 }
17341744
@@ -1913,10 +1923,18 @@ return (function () {
19131923 }
19141924
19151925 var triggerSpecs = getTriggerSpecs ( elt ) ;
1916- var explicitAction = processVerbs ( elt , nodeData , triggerSpecs ) ;
1917-
1918- if ( ! explicitAction && getClosestAttributeValue ( elt , "hx-boost" ) === "true" ) {
1919- boostElement ( elt , nodeData , triggerSpecs ) ;
1926+ var hasExplicitHttpAction = processVerbs ( elt , nodeData , triggerSpecs ) ;
1927+
1928+ if ( ! hasExplicitHttpAction ) {
1929+ if ( getClosestAttributeValue ( elt , "hx-boost" ) === "true" ) {
1930+ boostElement ( elt , nodeData , triggerSpecs ) ;
1931+ } else if ( hasAttribute ( elt , 'hx-trigger' ) ) {
1932+ triggerSpecs . forEach ( function ( triggerSpec ) {
1933+ // For "naked" triggers, don't do anything at all
1934+ addTriggerHandler ( elt , triggerSpec , nodeData , function ( ) {
1935+ } )
1936+ } )
1937+ }
19201938 }
19211939
19221940 if ( elt . tagName === "FORM" ) {
@@ -2037,6 +2055,8 @@ return (function () {
20372055 return ;
20382056 }
20392057
2058+ url = normalizePath ( url ) ;
2059+
20402060 var historyCache = parseJSON ( localStorage . getItem ( "htmx-history-cache" ) ) || [ ] ;
20412061 for ( var i = 0 ; i < historyCache . length ; i ++ ) {
20422062 if ( historyCache [ i ] . url === url ) {
@@ -2066,6 +2086,8 @@ return (function () {
20662086 return null ;
20672087 }
20682088
2089+ url = normalizePath ( url ) ;
2090+
20692091 var historyCache = parseJSON ( localStorage . getItem ( "htmx-history-cache" ) ) || [ ] ;
20702092 for ( var i = 0 ; i < historyCache . length ; i ++ ) {
20712093 if ( historyCache [ i ] . url === url ) {
@@ -3515,6 +3537,7 @@ return (function () {
35153537 internalData . xhr . abort ( ) ;
35163538 }
35173539 } ) ;
3540+ var originalPopstate = window . onpopstate ;
35183541 window . onpopstate = function ( event ) {
35193542 if ( event . state && event . state . htmx ) {
35203543 restoreHistory ( ) ;
@@ -3524,6 +3547,10 @@ return (function () {
35243547 'triggerEvent' : triggerEvent
35253548 } ) ;
35263549 } ) ;
3550+ } else {
3551+ if ( originalPopstate ) {
3552+ originalPopstate ( event ) ;
3553+ }
35273554 }
35283555 } ;
35293556 setTimeout ( function ( ) {
0 commit comments