@wordpress/router
Advanced tools
Comparing version 0.23.0 to 0.24.0
@@ -9,3 +9,3 @@ /** | ||
*/ | ||
import { addQueryArgs, getQueryArgs, removeQueryArgs } from '@wordpress/url'; | ||
import { buildQueryString } from '@wordpress/url'; | ||
const history = createBrowserHistory(); | ||
@@ -15,12 +15,12 @@ const originalHistoryPush = history.push; | ||
function push(params, state) { | ||
const currentArgs = getQueryArgs(window.location.href); | ||
const currentUrlWithoutArgs = removeQueryArgs(window.location.href, ...Object.keys(currentArgs)); | ||
const newUrl = addQueryArgs(currentUrlWithoutArgs, params); | ||
return originalHistoryPush.call(history, newUrl, state); | ||
const search = buildQueryString(params); | ||
return originalHistoryPush.call(history, { | ||
search | ||
}, state); | ||
} | ||
function replace(params, state) { | ||
const currentArgs = getQueryArgs(window.location.href); | ||
const currentUrlWithoutArgs = removeQueryArgs(window.location.href, ...Object.keys(currentArgs)); | ||
const newUrl = addQueryArgs(currentUrlWithoutArgs, params); | ||
return originalHistoryReplace.call(history, newUrl, state); | ||
const search = buildQueryString(params); | ||
return originalHistoryReplace.call(history, { | ||
search | ||
}, state); | ||
} | ||
@@ -27,0 +27,0 @@ history.push = push; |
@@ -21,12 +21,12 @@ "use strict"; | ||
function push(params, state) { | ||
const currentArgs = (0, _url.getQueryArgs)(window.location.href); | ||
const currentUrlWithoutArgs = (0, _url.removeQueryArgs)(window.location.href, ...Object.keys(currentArgs)); | ||
const newUrl = (0, _url.addQueryArgs)(currentUrlWithoutArgs, params); | ||
return originalHistoryPush.call(history, newUrl, state); | ||
const search = (0, _url.buildQueryString)(params); | ||
return originalHistoryPush.call(history, { | ||
search | ||
}, state); | ||
} | ||
function replace(params, state) { | ||
const currentArgs = (0, _url.getQueryArgs)(window.location.href); | ||
const currentUrlWithoutArgs = (0, _url.removeQueryArgs)(window.location.href, ...Object.keys(currentArgs)); | ||
const newUrl = (0, _url.addQueryArgs)(currentUrlWithoutArgs, params); | ||
return originalHistoryReplace.call(history, newUrl, state); | ||
const search = (0, _url.buildQueryString)(params); | ||
return originalHistoryReplace.call(history, { | ||
search | ||
}, state); | ||
} | ||
@@ -33,0 +33,0 @@ history.push = push; |
@@ -5,2 +5,4 @@ <!-- Learn how to maintain this file at https://github.com/WordPress/gutenberg/tree/HEAD/packages#maintaining-changelogs. --> | ||
## 0.24.0 (2024-04-03) | ||
## 0.23.0 (2024-03-21) | ||
@@ -7,0 +9,0 @@ |
{ | ||
"name": "@wordpress/router", | ||
"version": "0.23.0", | ||
"version": "0.24.0", | ||
"description": "Router API for WordPress pages.", | ||
@@ -29,6 +29,6 @@ "author": "The WordPress Contributors", | ||
"@babel/runtime": "^7.16.0", | ||
"@wordpress/element": "^5.31.0", | ||
"@wordpress/private-apis": "^0.36.0", | ||
"@wordpress/url": "^3.55.0", | ||
"history": "^5.1.0" | ||
"@wordpress/element": "^5.32.0", | ||
"@wordpress/private-apis": "^0.37.0", | ||
"@wordpress/url": "^3.56.0", | ||
"history": "^5.3.0" | ||
}, | ||
@@ -41,3 +41,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "ffc07735d0abfb3f69e91d48f25b7fe8d1ef92d2" | ||
"gitHead": "ac2b13783c28f959770cf029a797a712f59e1958" | ||
} |
@@ -9,3 +9,3 @@ /** | ||
*/ | ||
import { addQueryArgs, getQueryArgs, removeQueryArgs } from '@wordpress/url'; | ||
import { buildQueryString } from '@wordpress/url'; | ||
@@ -18,19 +18,9 @@ const history = createBrowserHistory(); | ||
function push( params, state ) { | ||
const currentArgs = getQueryArgs( window.location.href ); | ||
const currentUrlWithoutArgs = removeQueryArgs( | ||
window.location.href, | ||
...Object.keys( currentArgs ) | ||
); | ||
const newUrl = addQueryArgs( currentUrlWithoutArgs, params ); | ||
return originalHistoryPush.call( history, newUrl, state ); | ||
const search = buildQueryString( params ); | ||
return originalHistoryPush.call( history, { search }, state ); | ||
} | ||
function replace( params, state ) { | ||
const currentArgs = getQueryArgs( window.location.href ); | ||
const currentUrlWithoutArgs = removeQueryArgs( | ||
window.location.href, | ||
...Object.keys( currentArgs ) | ||
); | ||
const newUrl = addQueryArgs( currentUrlWithoutArgs, params ); | ||
return originalHistoryReplace.call( history, newUrl, state ); | ||
const search = buildQueryString( params ); | ||
return originalHistoryReplace.call( history, { search }, state ); | ||
} | ||
@@ -37,0 +27,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
60087
297
+ Added@wordpress/private-apis@0.37.0(transitive)
- Removed@wordpress/private-apis@0.36.0(transitive)
Updated@wordpress/element@^5.32.0
Updated@wordpress/url@^3.56.0
Updatedhistory@^5.3.0