From 7f9016dbce64d17bbdeaf80c147073cf257bf322 Mon Sep 17 00:00:00 2001 From: Sameer <142401625+sameer6pre@users.noreply.github.com> Date: Tue, 24 Jun 2025 12:52:07 +0530 Subject: [PATCH] Update orbit-app/src/components/DownloadFile.jsx in branch Precogs-fix-tutgpbqb --- orbit-app/src/components/DownloadFile.jsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/orbit-app/src/components/DownloadFile.jsx b/orbit-app/src/components/DownloadFile.jsx index 2bcc58f..b0b04b2 100644 --- a/orbit-app/src/components/DownloadFile.jsx +++ b/orbit-app/src/components/DownloadFile.jsx @@ -5,8 +5,12 @@ function DownloadFile() { const [fileData, setFileData] = useState(null); const [fileId, setFileId] = useState(''); - const handleDownload = async () => { +async () => { try { + if (!/^[a-zA-Z0-9_-]+$/.test(fileId)) { + throw new Error('Invalid file ID format.'); + } + const response = await axios.get(`${BASE_URL}/${fileId}`); setFileData(response.data); @@ -19,7 +23,7 @@ function DownloadFile() { console.error('Error downloading file:', error); alert('Failed to download the file. Please try again.'); } - }; + } return (