Skip to content

Commit

Permalink
Merge pull request #2458 from near/fix-add-params-to-url
Browse files Browse the repository at this point in the history
fix: use `.replace` to update query params
  • Loading branch information
MaximusHaximus authored Feb 8, 2022
2 parents 724ea63 + 157567e commit c8c2e36
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/frontend/src/redux/actions/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export const allowLogin = () => async (dispatch, getState) => {
const allKeys = availableKeys.map(key => key.toString());
const url = new URL(successUrl);
const originalSearchParams = parse(url.search);
window.location = `${url.origin}${url.pathname}?${stringify(
window.location = successUrl.replace(url.search, `?${stringify(
{
...originalSearchParams,
account_id: wallet.accountId,
Expand All @@ -221,7 +221,7 @@ export const allowLogin = () => async (dispatch, getState) => {
skipNull: true,
arrayFormat: "comma"
}
)}`;
)}`);
} else {
await dispatch(withAlert(addAccessKey(wallet.accountId, contractId, publicKey, false, methodNames), { data: { title } }));
dispatch(redirectTo('/authorized-apps', { globalAlertPreventClear: true }));
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/redux/slices/sign/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ export const handleSignTransactions = createAsyncThunk(
export function addQueryParams(baseUrl, queryParams = {}) {
const url = new URL(baseUrl);
const originalSearchParams = parse(url.search);
return `${url.origin}${url.pathname}?${stringify({...originalSearchParams, ...queryParams}, {
return baseUrl.replace(url.search,`?${stringify({...originalSearchParams, ...queryParams}, {
skipEmptyString: true,
skipNull: true,
})}`;
})}`);
}

export const removeSuccessTransactions = ({ transactions, successHashes }) => {
Expand Down

0 comments on commit c8c2e36

Please sign in to comment.