Skip to content

Commit

Permalink
XLabs/portal-bridge-ui-issues#11 - add redirects for legacy routes
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianscatularo committed Dec 5, 2023
1 parent 4a0de49 commit adad11f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion apps/connect/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions apps/connect/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ import theme from "./theme/portal.ts";
import Background from "./components/atoms/Background.tsx";
import App from "./App.tsx";

if (redirects) {
const matcher = new RegExp(redirects.join("|"));
const hash = window.location.hash;
if (matcher.test(hash)) {
window.location.href = `${advancedToolsHref}${hash}`
}
}

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<ThemeProvider theme={theme}>
Expand Down
2 changes: 2 additions & 0 deletions apps/connect/src/vite-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ type NavLink = {
declare global {
declare const wormholeConnectConfig: WormholeConnectConfig;
declare const navBar: NavLink[];
declare const redirects: string[] | undefined;
declare const advancedToolsHref: string;
}
22 changes: 20 additions & 2 deletions apps/connect/vite.token-bridge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import viteConfig from './vite.config'

const PUBLIC_URL = viteConfig.base;

const ADVANCE_TOOLS_HREF = `${PUBLIC_URL}/advanced-tools/#/transfer`
const ADVANCE_TOOLS_HREF_TEMPLATE = `${ADVANCE_TOOLS_HREF}?sourceChain={:sourceChain}&targetChain={:targetChain}`
const ADVANCE_TOOLS_HREF = `${PUBLIC_URL}/advanced-tools/`
const ADVANCE_TOOLS_HREF_TEMPLATE = `${ADVANCE_TOOLS_HREF}#/transfer?sourceChain={:sourceChain}&targetChain={:targetChain}`
const USDC_BRIDGE_HREF = `${PUBLIC_URL}/usdc-bridge/`

const ALGORAND = {
Expand Down Expand Up @@ -45,6 +45,24 @@ export default defineConfig({
{ label: "Home", active: true, href: `${PUBLIC_URL}/` },
{ label: "USDC", href: USDC_BRIDGE_HREF }
],
advancedToolsHref: ADVANCE_TOOLS_HREF,
redirects: [
"#/nft",
"#/redeem",
"#/nft-origin-verifier",
"#/token-origin-verifier",
"#/register",
"#/migrate/Ethereum/:legacyAsset/",
"#/migrate/BinanceSmartChain/:legacyAsset/",
"#/migrate/Celo/:legacyAsset/",
"#/migrate/Ethereum/",
"#/migrate/BinanceSmartChain/",
"#/migrate/Celo/",
"#/stats",
"#/withdraw-tokens-terra",
"#/unwrap-native",
"#/custody-addresses"
],
wormholeConnectConfig: {
...viteConfig?.define?.wormholeConnectConfig,
cctpWarning: {
Expand Down

0 comments on commit adad11f

Please sign in to comment.