@@ -77,7 +77,14 @@ const locationHistoryMiddleware: Route.ClientMiddlewareFunction = async ({ reque
7777 console . log ( '[locationHistoryMiddleware] Failed to store location history entry' , err ) ;
7878 }
7979} ;
80-
80+ const sanitizeUrlAndExtractOrigin = ( url : string ) => {
81+ try {
82+ const parsed = new URL ( url ) ;
83+ return parsed . origin ;
84+ } catch {
85+ return '' ;
86+ }
87+ } ;
8188export const clientMiddleware : Route . ClientMiddlewareFunction [ ] = [ locationHistoryMiddleware ] ;
8289
8390export const ErrorBoundary : FC < Route . ErrorBoundaryProps > = ( { error } ) => {
@@ -344,18 +351,28 @@ const Root = () => {
344351
345352 return logoutSubmit ( ) ;
346353 }
354+ // Supports params: uri, curl, origin
347355 if ( urlWithoutParams === 'insomnia://app/import' ) {
348356 window . main . trackSegmentEvent ( {
349357 event : SegmentEvent . importStarted ,
350358 properties : {
351359 source : 'import-url' ,
352360 } ,
353361 } ) ;
362+
354363 if ( params . uri ) {
355- return setImportObject ( { type : 'uri' , defaultValue : params . uri , origin : params . origin } ) ;
364+ return setImportObject ( {
365+ type : 'uri' ,
366+ defaultValue : params . uri ,
367+ origin : sanitizeUrlAndExtractOrigin ( params . origin ) ,
368+ } ) ;
356369 }
357370 if ( params . curl ) {
358- return setImportObject ( { type : 'curl' , defaultValue : params . curl , origin : params . origin } ) ;
371+ return setImportObject ( {
372+ type : 'curl' ,
373+ defaultValue : params . curl ,
374+ origin : sanitizeUrlAndExtractOrigin ( params . origin ) ,
375+ } ) ;
359376 }
360377 }
361378 if ( urlWithoutParams === 'insomnia://plugins/install' ) {
0 commit comments