From 720cc9058889482948c8b0085e8a0d321df36733 Mon Sep 17 00:00:00 2001
From: Dima Rifai <dima.rifai@gmail.com>
Date: Mon, 6 Jan 2025 13:26:54 +0200
Subject: [PATCH] Issue #412 - Validate Account in route starts with @ and is
 not empty

---
 pages/balanceHistory/[accountName].tsx | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/pages/balanceHistory/[accountName].tsx b/pages/balanceHistory/[accountName].tsx
index d7f9ba59..3950878a 100644
--- a/pages/balanceHistory/[accountName].tsx
+++ b/pages/balanceHistory/[accountName].tsx
@@ -20,6 +20,7 @@ import BalanceHistorySearch from "@/components/home/searches/BalanceHistorySearc
 import { Card, CardHeader } from "@/components/ui/card";
 import BalanceHistoryChart from "@/components/balanceHistory/BalanceHistoryChart";
 
+import ErrorPage from "../ErrorPage";
 // Memoizing the BalanceHistoryChart component to avoid unnecessary re-renders
 const MemoizedBalanceHistoryChart = React.memo(BalanceHistoryChart);
 
@@ -172,6 +173,16 @@ export default function BalanceHistory() {
     message = "Showing Results with applied filters.";
   }
 
+   // get the accountName
+   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 />;
+  }
+  
   return (
     <>
       <Head>
-- 
GitLab