From 376272da4216721d5834ec3cdf2ff3704022c5b5 Mon Sep 17 00:00:00 2001 From: impelcrypto Date: Fri, 3 Jan 2025 18:01:16 +0800 Subject: [PATCH] fix: redirect to assets page after changing the network --- .gitignore | 2 ++ src/router/utils/index.ts | 20 +++++--------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index b730a6afe..9088eeb7e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .DS_Store .thumbs.db node_modules +.env # Quasar core related directories .quasar @@ -52,3 +53,4 @@ astar-collator # Chopstick binaries db.sqlite* +.vercel \ No newline at end of file diff --git a/src/router/utils/index.ts b/src/router/utils/index.ts index 14f87dad7..ed17308c7 100644 --- a/src/router/utils/index.ts +++ b/src/router/utils/index.ts @@ -44,25 +44,15 @@ export const buildXvmTransferPageLink = (symbol: string): string => { }; /** - * A helper function to replace the network params to the selected network - * EX: `http://localhost:8080/shiden/assets` -> `http://localhost:8080/astar/assets` + * A helper function to build the URL and redirect to the selected network's assets page + * EX: `http://localhost:8080/shiden/bridge` -> `http://localhost:8080/astar/assets` * @param network networkAlias in providerEndpoints - * @returns URL */ export const buildNetworkUrl = (network: string) => { const href = window.location.href; const hrefArray = href.split('/'); - const networkIndex = 3; - - const url = hrefArray - .slice(0, hrefArray.length) - .map((it: string, index: number) => (index === networkIndex ? network : it)) - .join('/'); - - // Memo: `window.open(url, '_self')` won't work with `#` - if (url.includes('#staking')) { - return url.replace('#staking', ''); - } - + // Memo: Extract the protocol + host + const host = hrefArray.slice(0, 3).join('/'); + const url = `${host}/${network}${Path.Assets}`; return url; };