Skip to content

Commit

Permalink
fix: legacy redirect for accounts (#783)
Browse files Browse the repository at this point in the history
coinmarketcap.com was linking to an old address that was an account page
with no account supplied.
  • Loading branch information
ckniffen authored Jul 19, 2023
1 parent 8aa684f commit 5a101f6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/containers/App/legacyRedirects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}/`
}
}

Expand Down
15 changes: 15 additions & 0 deletions src/containers/App/test/App.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 5a101f6

Please sign in to comment.