Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Update frontend/src/pages/ScanResults.jsx
Browse files
frontend/src/pages/ScanResults.jsx
CHANGED
|
@@ -194,8 +194,26 @@ export const ScanResults = () => {
|
|
| 194 |
const blob = await res.blob();
|
| 195 |
const url = window.URL.createObjectURL(blob);
|
| 196 |
const a = document.createElement('a');
|
| 197 |
-
|
| 198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
document.body.appendChild(a);
|
| 200 |
a.click();
|
| 201 |
a.remove();
|
|
|
|
| 194 |
const blob = await res.blob();
|
| 195 |
const url = window.URL.createObjectURL(blob);
|
| 196 |
const a = document.createElement('a');
|
| 197 |
+
let filename = '';
|
| 198 |
+
const disposition = res.headers.get('Content-Disposition');
|
| 199 |
+
if (disposition && disposition.includes('filename=')) {
|
| 200 |
+
const match = disposition.match(/filename="?([^";]+)"?/);
|
| 201 |
+
if (match && match[1]) {
|
| 202 |
+
filename = match[1];
|
| 203 |
+
}
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
if (!filename) {
|
| 207 |
+
const orgName = scan.org_name || scan.organization_name || 'Global';
|
| 208 |
+
const cleanOrg = orgName.replace(/[^\w]/g, '') || 'Organization';
|
| 209 |
+
const dateObj = new Date(scan.completed_at || scan.started_at || Date.now());
|
| 210 |
+
const day = String(dateObj.getDate()).padStart(2, '0');
|
| 211 |
+
const month = String(dateObj.getMonth() + 1).padStart(2, '0');
|
| 212 |
+
const year = dateObj.getFullYear();
|
| 213 |
+
filename = `LarShield_${cleanOrg}_Report_${day}${month}${year}.pdf`;
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
a.download = filename;
|
| 217 |
document.body.appendChild(a);
|
| 218 |
a.click();
|
| 219 |
a.remove();
|