Download wp-calypso/client/performance-profiler/utils/query-params.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 618 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/performance-profiler/utils/query-params.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/performance-profiler/utils/query-params.ts
-
curl -L -o query-params.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/performance-profiler/utils/query-params.ts
618 Bytes
| import page from '@automattic/calypso-router'; | |
| export const updateQueryParams = ( params: Record< string, string >, forceReload = false ) => { | |
| const queryParams = new URLSearchParams( window.location.search ); | |
| Object.keys( params ).forEach( ( key ) => { | |
| if ( params[ key ] ) { | |
| queryParams.set( key, params[ key ] ); | |
| } | |
| } ); | |
| // If forceReload is true, we want to reload the page with the new query params instead of just updating the URL | |
| if ( forceReload ) { | |
| page( `/speed-test-tool?${ queryParams.toString() }` ); | |
| } else { | |
| window.history.replaceState( {}, '', `?${ queryParams.toString() }` ); | |
| } | |
| }; | |