Skip to content

Commit

Permalink
Merge pull request #698 from SoftwareBrothers/fix/append-refresh
Browse files Browse the repository at this point in the history
fix: update appendForceRefresh to append refresh to existing params
  • Loading branch information
SimonB407 authored Dec 3, 2020
2 parents 9b6e1d9 + 521ac77 commit dab1cdf
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/frontend/components/actions/utils/append-force-refresh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ export const REFRESH_KEY = 'refresh'
* @private
*/
export const appendForceRefresh = (url: string, search?: string): string => {
const params = new URLSearchParams(search ?? window.location.search)
params.set(REFRESH_KEY, 'true')
return `${url}?${params}`
const urlObject = new URL(url)
const oldParams = search ?? urlObject.search ?? window.location.search
const newParams = new URLSearchParams(oldParams)

newParams.set(REFRESH_KEY, 'true')
return `${urlObject.origin}${urlObject.pathname}?${newParams.toString()}`
}

export const hasForceRefresh = (search: string): boolean => {
Expand Down

0 comments on commit dab1cdf

Please sign in to comment.