Skip to content

Commit 1fd71b6

Browse files
Hari KiranHari Kiran
authored andcommitted
Fix Preview bug
1 parent 98aeaf7 commit 1fd71b6

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/pages/DatasetDetailPage.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,21 @@ const DatasetDetailPage: React.FC = () => {
402402
};
403403

404404
const extractFileName = (url: string): string => {
405-
const match = url.match(/file=([^&]+)/);
406-
return match ? decodeURIComponent(match[1]) : url;
405+
const match = url.match(/file=([^&]+)/);
406+
// return match ? decodeURIComponent(match[1]) : url;
407+
if (match) {
408+
// Strip any trailing query parameters
409+
const raw = decodeURIComponent(match[1]);
410+
return raw.split("?")[0].split("&")[0];
411+
}
412+
// fallback: try to get last path part if no 'file=' param
413+
try {
414+
const u = new URL(url);
415+
const parts = u.pathname.split("/");
416+
return parts[parts.length - 1];
417+
} catch {
418+
return url;
419+
}
407420
};
408421

409422
const isPreviewableFile = (fileName: string): boolean => {

0 commit comments

Comments
 (0)