From 5a101f6475d40cd369bafeb3e675d964652bbdd7 Mon Sep 17 00:00:00 2001 From: Caleb Kniffen Date: Wed, 19 Jul 2023 11:34:02 -0500 Subject: [PATCH] fix: legacy redirect for accounts (#783) coinmarketcap.com was linking to an old address that was an account page with no account supplied. --- src/containers/App/legacyRedirects.tsx | 8 ++++++-- src/containers/App/test/App.test.jsx | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/containers/App/legacyRedirects.tsx b/src/containers/App/legacyRedirects.tsx index 0a2cab68e..f02b1bee8 100644 --- a/src/containers/App/legacyRedirects.tsx +++ b/src/containers/App/legacyRedirects.tsx @@ -9,9 +9,13 @@ export const legacyRedirect = ( const identifier = location.hash.split('#/transactions/')[1] return `${basename}/transactions/${identifier}` } - if (location.hash.indexOf('#/graph/') === 0) { + if (location.hash.indexOf('#/graph') === 0) { const identifier = location.hash.split('#/graph/')[1] - return `${basename}/accounts/${identifier}` + if (identifier) { + return `${basename}/accounts/${identifier}` + } + + return `${basename}/` } } diff --git a/src/containers/App/test/App.test.jsx b/src/containers/App/test/App.test.jsx index 10846db8e..98b7baf12 100644 --- a/src/containers/App/test/App.test.jsx +++ b/src/containers/App/test/App.test.jsx @@ -391,6 +391,21 @@ describe('App container', () => { }) }) + it('redirects legacy account page with no account', () => { + wrapper = createWrapper(`/#/graph/`) + return new Promise((r) => setTimeout(r, 10)).then(() => { + expect(document.title).toEqual(`xrpl_explorer | ledgers`) + expect(window.dataLayer).toEqual([ + { + page_path: '/', + page_title: 'xrpl_explorer | ledgers', + event: 'screen_view', + network: 'mainnet', + }, + ]) + }) + }) + it('renders custom mode homepage', async () => { process.env.VITE_ENVIRONMENT = 'custom' delete process.env.VITE_P2P_RIPPLED_HOST // For custom as there is no p2p.