File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
packages/experiment-browser/src/providers Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -119,14 +119,20 @@ export class DefaultUserProvider implements ExperimentUserProvider {
119119
120120 private getUrlParam ( ) : Record < string , string | string [ ] > {
121121 if ( ! this . globalScope ) {
122- return { } ;
122+ return undefined ;
123123 }
124124
125125 const params : Record < string , string [ ] > = { } ;
126- for ( const [ name , value ] of new URL ( this . globalScope ?. location ?. href )
127- . searchParams ) {
128- params [ name ] = [ ...( params [ name ] ?? [ ] ) , ...value . split ( ',' ) ] ;
126+
127+ try {
128+ const url = new URL ( this . globalScope . location . href ) ;
129+ for ( const [ name , value ] of url . searchParams ) {
130+ params [ name ] = [ ...( params [ name ] ?? [ ] ) , ...value . split ( ',' ) ] ;
131+ }
132+ } catch ( error ) {
133+ return undefined ;
129134 }
135+
130136 return Object . entries ( params ) . reduce < Record < string , string | string [ ] > > (
131137 ( acc , [ name , value ] ) => {
132138 acc [ name ] = value . length == 1 ? value [ 0 ] : value ;
You can’t perform that action at this time.
0 commit comments