Skip to content
Snippets Groups Projects
Commit 8667ffbf authored by Dima Rifai's avatar Dima Rifai Committed by mcfarhat
Browse files

Issue #412 - Validate Account in route starts with @ and is not empty

parent 42aa87fb
No related branches found
No related tags found
1 merge request!511Delrifai/#412 verify account starts with @
...@@ -24,7 +24,7 @@ import { Button } from "@/components/ui/button"; ...@@ -24,7 +24,7 @@ import { Button } from "@/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import useConvertedAccountDetails from "@/hooks/common/useConvertedAccountDetails"; import useConvertedAccountDetails from "@/hooks/common/useConvertedAccountDetails";
import useDynamicGlobal from "@/hooks/api/homePage/useDynamicGlobal"; import useDynamicGlobal from "@/hooks/api/homePage/useDynamicGlobal";
import ErrorPage from "./ErrorPage";
interface AccountSearchParams { interface AccountSearchParams {
accountName?: string | undefined; accountName?: string | undefined;
fromBlock: number | undefined; fromBlock: number | undefined;
...@@ -98,6 +98,7 @@ export default function Account() { ...@@ -98,6 +98,7 @@ export default function Account() {
liveDataEnabled, liveDataEnabled,
dynamicGlobalData dynamicGlobalData
); );
const accountOperationsProps = { const accountOperationsProps = {
accountName: accountNameFromRoute, accountName: accountNameFromRoute,
operationTypes: filtersParam.length operationTypes: filtersParam.length
...@@ -277,6 +278,15 @@ export default function Account() { ...@@ -277,6 +278,15 @@ export default function Account() {
} }
}; };
// get the accountName and treat it as a string
const routeAccountName = Array.isArray(router.query.accountName)
? router.query.accountName[0] // If it's an array, get the first element
: router.query.accountName; // Otherwise, treat it as a string directly
if(routeAccountName && !routeAccountName.startsWith("@") || !accountNameFromRoute)
{
return <ErrorPage />;
}
if (!accountDetails) { if (!accountDetails) {
return ( return (
<Loader2 className="animate-spin mt-1 text-black dark:text-white h-12 w-12 ml-3 ..." /> <Loader2 className="animate-spin mt-1 text-black dark:text-white h-12 w-12 ml-3 ..." />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment