Skip to content

Commit

Permalink
Merge pull request #3139 from near/master
Browse files Browse the repository at this point in the history
Release 2024-05-29
  • Loading branch information
andy-haynes authored May 29, 2024
2 parents 1039b69 + ed4b0a0 commit 577e32f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/frontend/src/components/Routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import { PageNotFound } from './page-not-found/PageNotFound';
import Privacy from './privacy/Privacy';
import Terms from './terms/Terms';
import { initAnalytics } from './wallet-migration/metrics';
import RecoveryRedirect from './wallet-migration/RecoveryRedirect';
import { getMigrationStep } from './wallet-migration/utils';
import WalletMigration, { WALLET_MIGRATION_VIEWS } from './wallet-migration/WalletMigration';
import '../index.css';
Expand Down Expand Up @@ -420,6 +421,11 @@ class Routing extends Component {
component={VerifyOwnerWrapper}
/>
)}
<Route
exact
path="/recover-with-link/:accountId/:seedPhrase"
component={RecoveryRedirect}
/>
<PrivateRoute component={PageNotFound} />
</Switch>
<Footer />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';

import { IS_MAINNET } from '../../config';

const RedirectToTestnet = () => {
const location = useLocation();

useEffect(() => {
// Function to reconstruct the URL
const reconstructUrl = (url) => {
const urlObj = new URL(url);
const myNearWalletUrl = IS_MAINNET ? 'https://app.mynearwallet.com/' : 'https://testnet.mynearwallet.com';
const newUrl = new URL(myNearWalletUrl);
newUrl.pathname = urlObj.pathname;
newUrl.search = urlObj.search;
newUrl.hash = urlObj.hash;
return newUrl.toString();
};

// Get the current URL
const currentUrl = window.location.href;

// Reconstruct the URL
const newUrl = reconstructUrl(currentUrl);

// Redirect to the new URL
window.location.replace(newUrl);
}, [location]);

return null;
};

export default RedirectToTestnet;

0 comments on commit 577e32f

Please sign in to comment.