File tree Expand file tree Collapse file tree 4 files changed +23
-17
lines changed
Expand file tree Collapse file tree 4 files changed +23
-17
lines changed Original file line number Diff line number Diff line change @@ -147,9 +147,15 @@ export default defineComponent({
147147 populateAuthorizationToken ();
148148 stripTokenFromUrl ();
149149
150- const urlParams = normalizeUrlParams (
151- vtkURLExtract .extractURLParameters () as UrlParams
152- );
150+ let urlParams: ReturnType <typeof normalizeUrlParams >;
151+ try {
152+ urlParams = normalizeUrlParams (
153+ vtkURLExtract .extractURLParameters () as UrlParams
154+ );
155+ } catch (error ) {
156+ console .error (' Failed to parse URL parameters:' , error );
157+ urlParams = {};
158+ }
153159
154160 onMounted (() => {
155161 loadUrls (urlParams );
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { getRequestPool } from '@/src/core/streaming/requestPool';
44import { ImportHandler , asIntermediateResult } from '@/src/io/import/common' ;
55import { canFetchUrl } from '@/src/utils/fetch' ;
66import { extractFilenameFromContentDisposition } from '@/src/utils/parseContentDispositionHeader' ;
7+ import { basename } from '@/src/utils/path' ;
78
89const openUriStream : ImportHandler = async ( dataSource , context ) => {
910 if ( dataSource . type !== 'uri' || ! canFetchUrl ( dataSource . uri ) ) {
@@ -26,7 +27,7 @@ const openUriStream: ImportHandler = async (dataSource, context) => {
2627
2728 // Only use Content-Disposition if current name lacks an extension
2829 // (indicating it's likely auto-derived from URL like "download" or "getImage")
29- const hasExtension = dataSource . name . includes ( '.' ) ;
30+ const hasExtension = basename ( dataSource . name ) . lastIndexOf ( '.' ) > 0 ;
3031 const finalName =
3132 ! hasExtension && filenameFromHeader ? filenameFromHeader : dataSource . name ;
3233
Original file line number Diff line number Diff line change 11const CONTENT_DISPOSITION_FILENAME_REGEXP =
22 / f i l e n a m e \s * = \s * (?: " ( [ ^ " ] * ) " | ( [ ^ ; \s ] * ) ) / i;
33
4- export type ContentDisposition =
5- | { type : 'invalid' ; filename : null }
6- | { type : 'inline' ; filename : string | null }
7- | { type : 'attachment' ; filename : string | null } ;
4+ export type ContentDisposition = {
5+ type : 'inline' | 'attachment' | 'invalid' ;
6+ filename : string | null ;
7+ } ;
88
99export function parseContentDispositionHeader (
1010 headerValue : string | null
Original file line number Diff line number Diff line change @@ -18,6 +18,12 @@ const isValidUrl = (str: string) => {
1818 }
1919} ;
2020
21+ const splitAndClean = ( str : string ) =>
22+ str
23+ . split ( ',' )
24+ . map ( ( url ) => url . trim ( ) )
25+ . filter ( Boolean ) ;
26+
2127const parseUrlArray = ( value : string | string [ ] ) : string [ ] => {
2228 if ( Array . isArray ( value ) ) {
2329 return value . flatMap ( ( v ) => parseUrlArray ( v ) ) ;
@@ -28,18 +34,11 @@ const parseUrlArray = (value: string | string[]): string[] => {
2834 if ( ! trimmed ) return [ ] ;
2935
3036 if ( trimmed . startsWith ( '[' ) && trimmed . endsWith ( ']' ) ) {
31- const inner = trimmed . slice ( 1 , - 1 ) ;
32- return inner
33- . split ( ',' )
34- . map ( ( url ) => url . trim ( ) )
35- . filter ( Boolean ) ;
37+ return splitAndClean ( trimmed . slice ( 1 , - 1 ) ) ;
3638 }
3739
3840 if ( trimmed . includes ( ',' ) ) {
39- return trimmed
40- . split ( ',' )
41- . map ( ( url ) => url . trim ( ) )
42- . filter ( Boolean ) ;
41+ return splitAndClean ( trimmed ) ;
4342 }
4443
4544 return [ trimmed ] ;
You can’t perform that action at this time.
0 commit comments