File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -402,8 +402,21 @@ const DatasetDetailPage: React.FC = () => {
402402 } ;
403403
404404 const extractFileName = ( url : string ) : string => {
405- const match = url . match ( / f i l e = ( [ ^ & ] + ) / ) ;
406- return match ? decodeURIComponent ( match [ 1 ] ) : url ;
405+ const match = url . match ( / f i l e = ( [ ^ & ] + ) / ) ;
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 => {
You can’t perform that action at this time.
0 commit comments