Skip to content

Commit

Permalink
fix(useURLSearchParams): avoid referencing to global location (#2066)
Browse files Browse the repository at this point in the history
  • Loading branch information
mskr committed Aug 9, 2022
1 parent 6fea292 commit 4230032
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/core/useUrlSearchParams/index.ts
Expand Up @@ -64,9 +64,9 @@ export function useUrlSearchParams<T extends Record<string, any> = UrlParams>(
const stringified = params.toString()

if (mode === 'history')
return `${stringified ? `?${stringified}` : ''}${location.hash || ''}`
return `${stringified ? `?${stringified}` : ''}${window.location.hash || ''}`
if (mode === 'hash-params')
return `${location.search || ''}${stringified ? `#${stringified}` : ''}`
return `${window.location.search || ''}${stringified ? `#${stringified}` : ''}`
const hash = window.location.hash || '#'
const index = hash.indexOf('?')
if (index > 0)
Expand Down

0 comments on commit 4230032

Please sign in to comment.