From 745e675abd093713ba16d2fbc0d76c00e5831335 Mon Sep 17 00:00:00 2001 From: Mario Santos Date: Wed, 17 Apr 2024 11:59:24 +0200 Subject: [PATCH] Add check for anchor links of the same page --- packages/interactivity-router/src/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/interactivity-router/src/index.js b/packages/interactivity-router/src/index.js index de951f7e7d999..03d75bafa82f4 100644 --- a/packages/interactivity-router/src/index.js +++ b/packages/interactivity-router/src/index.js @@ -163,7 +163,8 @@ const isValidLink = ( ref ) => ref.origin === window.location.origin && ! ref.pathname.startsWith( '/wp-admin' ) && ! ref.pathname.startsWith( '/wp-login.php' ) && - ! new URL( ref.href ).searchParams.get( '_wpnonce' ); + ! ref.getAttribute( 'href' ).startsWith( '#' ) && + ! new URL( ref.href ).searchParams.has( '_wpnonce' ); // Check if the event is valid for client-side navigation. const isValidEvent = ( event ) =>