Skip to content

Commit

Permalink
Router: update history package to 5.3.0, fix query string generation (W…
Browse files Browse the repository at this point in the history
…ordPress#60271)

Co-authored-by: jsnajdr <jsnajdr@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
  • Loading branch information
3 people authored and cbravobernal committed Apr 9, 2024
1 parent 0e72702 commit 6eb6c09
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@wordpress/element": "file:../element",
"@wordpress/private-apis": "file:../private-apis",
"@wordpress/url": "file:../url",
"history": "^5.1.0"
"history": "^5.3.0"
},
"peerDependencies": {
"react": "^18.0.0"
Expand Down
9 changes: 2 additions & 7 deletions packages/router/src/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,13 @@ const history = createBrowserHistory();
const originalHistoryPush = history.push;
const originalHistoryReplace = history.replace;

function buildSearch( params ) {
const queryString = buildQueryString( params );
return queryString.length > 0 ? '?' + queryString : queryString;
}

function push( params, state ) {
const search = buildSearch( params );
const search = buildQueryString( params );
return originalHistoryPush.call( history, { search }, state );
}

function replace( params, state ) {
const search = buildSearch( params );
const search = buildQueryString( params );
return originalHistoryReplace.call( history, { search }, state );
}

Expand Down

0 comments on commit 6eb6c09

Please sign in to comment.