Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 5x 5x 4x 4x 4x 4x 5x 5x 2x 2x 2x 2x | export const getQueryParam: (key: string) => string | null | undefined = (key) => { if (typeof window !== 'undefined') { const url = new URL(location.href); return url.searchParams.get(key); } }; export const setQueryParam: (key: string, value: string) => void = (key, value) => { Eif (typeof window !== 'undefined') { const url = new URL(location.href); url.searchParams.set(key, value); window.history.replaceState(null, '', url.href); } }; export const setQueryParams: (params: { key: string, value: string }[]) => void = (params) => { if (typeof window !== 'undefined') { const url = new URL(location.href); params.forEach(({ key, value }) => url.searchParams.set(key, value)); window.history.replaceState(null, '', url.href); } }; export const removeQueryParam: (key: string) => void = (key) => { Eif (typeof window !== 'undefined') { const url = new URL(location.href); url.searchParams.delete(key); window.history.replaceState(null, '', url.href); } }; |