-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: redirect old tx id URLs (#1870)
* Fix: redirect old tx id URLs * Update src/pages/404.tsx Co-authored-by: Aaron Cook <[email protected]> * Bump the version --------- Co-authored-by: Aaron Cook <[email protected]>
- Loading branch information
Showing
4 changed files
with
66 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { _getRedirectUrl } from '../../pages/404' | ||
|
||
describe('_getRedirectUrl', () => { | ||
it('moves a safe address from the path to the query', () => { | ||
const url = _getRedirectUrl({ | ||
pathname: '/eth:0xA77DE01e157f9f57C7c4A326eeE9C4874D0598b6/balances', | ||
search: '', | ||
} as Location) | ||
expect(url).toBe('/balances?safe=eth:0xA77DE01e157f9f57C7c4A326eeE9C4874D0598b6') | ||
}) | ||
|
||
it('returns undefined if the path is not a safe address', () => { | ||
const url = _getRedirectUrl({ | ||
pathname: '/welcome', | ||
search: '', | ||
} as Location) | ||
expect(url).toBeUndefined() | ||
}) | ||
|
||
it('preserves query parameters', () => { | ||
const url = _getRedirectUrl({ | ||
pathname: '/eth:0xA77DE01e157f9f57C7c4A326eeE9C4874D0598b6/transactions/history', | ||
search: '?foo=bar&baz=qux', | ||
} as Location) | ||
expect(url).toBe('/transactions/history?safe=eth:0xA77DE01e157f9f57C7c4A326eeE9C4874D0598b6&foo=bar&baz=qux') | ||
}) | ||
|
||
it('rewrites tx id from path to query', () => { | ||
const url = _getRedirectUrl({ | ||
pathname: | ||
'/eth:0xA77DE01e157f9f57C7c4A326eeE9C4874D0598b6/transactions/multisig_0xA77DE01e157f9f57C7c4A326eeE9C4874D0598b6_0x102f72ce18d977a144ddef78c1f35a3102d04e94cc39e3e59d874874f22a7ec2', | ||
search: '', | ||
} as Location) | ||
expect(url).toBe( | ||
'/transactions/tx?safe=eth:0xA77DE01e157f9f57C7c4A326eeE9C4874D0598b6&id=multisig_0xA77DE01e157f9f57C7c4A326eeE9C4874D0598b6_0x102f72ce18d977a144ddef78c1f35a3102d04e94cc39e3e59d874874f22a7ec2', | ||
) | ||
}) | ||
|
||
it('does not rewrite other transaction routes', () => { | ||
const url = _getRedirectUrl({ | ||
pathname: '/eth:0xA77DE01e157f9f57C7c4A326eeE9C4874D0598b6/transactions/messages', | ||
search: '', | ||
} as Location) | ||
expect(url).toBe('/transactions/messages?safe=eth:0xA77DE01e157f9f57C7c4A326eeE9C4874D0598b6') | ||
}) | ||
}) |