@@ -140,31 +140,36 @@ describe('web options', () => {
140140
141141describe ( "Url param extraction" , ( ) => {
142142
143- it ( 'should return null on null url' , ( ) => {
143+ it ( 'should return undefined on null url' , ( ) => {
144144 const paramObj = WebUtils . getUrlParams ( null ! ) ;
145145 expect ( paramObj ) . toBeUndefined ( ) ;
146146 } ) ;
147147
148- it ( 'should return null on empty url' , ( ) => {
148+ it ( 'should return undefined on empty url' , ( ) => {
149149 const paramObj = WebUtils . getUrlParams ( "" ) ;
150150 expect ( paramObj ) . toBeUndefined ( ) ;
151151 } ) ;
152152
153- it ( 'should return null on url with spaces' , ( ) => {
153+ it ( 'should return undefined on url with spaces' , ( ) => {
154154 const paramObj = WebUtils . getUrlParams ( " " ) ;
155155 expect ( paramObj ) . toBeUndefined ( ) ;
156156 } ) ;
157157
158- it ( 'should return null if no params in url' , ( ) => {
158+ it ( 'should return undefined if no params in url' , ( ) => {
159159 const paramObj = WebUtils . getUrlParams ( "https://app.example.com/" ) ;
160160 expect ( paramObj ) . toBeUndefined ( ) ;
161161 } ) ;
162162
163- it ( 'should return null if no params in url' , ( ) => {
163+ it ( 'should return undefined if no params in url search ' , ( ) => {
164164 const paramObj = WebUtils . getUrlParams ( "https://app.example.com?" ) ;
165165 expect ( paramObj ) . toBeUndefined ( ) ;
166166 } ) ;
167167
168+ it ( 'should return undefined if no params in url hash' , ( ) => {
169+ const paramObj = WebUtils . getUrlParams ( "https://app.example.com#" ) ;
170+ expect ( paramObj ) . toBeUndefined ( ) ;
171+ } ) ;
172+
168173 it ( 'should remove invalid combinations one param' , ( ) => {
169174 const paramObj = WebUtils . getUrlParams ( "https://app.example.com?=test" ) ;
170175 expect ( paramObj ) . toBeUndefined ( ) ;
@@ -182,7 +187,7 @@ describe("Url param extraction", () => {
182187
183188 it ( 'should extract a uuid state param' , ( ) => {
184189 const state = WebUtils . randomString ( ) ;
185- const paramObj = WebUtils . getUrlParams ( " https://app.example.com?state=" + state + " &access_token=testtoken" ) ;
190+ const paramObj = WebUtils . getUrlParams ( ` https://app.example.com?state=${ state } &access_token=testtoken` ) ;
186191 expect ( paramObj ! [ "state" ] ) . toStrictEqual ( state ) ;
187192 } ) ;
188193
@@ -191,7 +196,15 @@ describe("Url param extraction", () => {
191196 const foo = WebUtils . randomString ( ) ;
192197 const paramObj = WebUtils . getUrlParams ( `https://app.example.com?random=${ random } &foo=${ foo } #ignored` ) ;
193198 expect ( paramObj ! [ "random" ] ) . toStrictEqual ( random ) ;
194- expect ( paramObj ! [ "foo" ] ) . toStrictEqual ( `${ foo } ` ) ;
199+ expect ( paramObj ! [ "foo" ] ) . toStrictEqual ( foo ) ;
200+ } ) ;
201+
202+ it ( 'should use query flag with another question mark in a param' , ( ) => {
203+ const random = WebUtils . randomString ( ) ;
204+ const foo = WebUtils . randomString ( ) ;
205+ const paramObj = WebUtils . getUrlParams ( `https://app.example.com?random=${ random } &foo=${ foo } ?questionmark` ) ;
206+ expect ( paramObj ! [ "random" ] ) . toStrictEqual ( random ) ;
207+ expect ( paramObj ! [ "foo" ] ) . toStrictEqual ( `${ foo } ?questionmark` ) ;
195208 } ) ;
196209
197210 it ( 'should use hash flag and ignore query flag' , ( ) => {
@@ -202,6 +215,14 @@ describe("Url param extraction", () => {
202215 expect ( paramObj ! [ "foo" ] ) . toStrictEqual ( `${ foo } ?ignored` ) ;
203216 } ) ;
204217
218+ it ( 'should use hash flag with another hash in a param' , ( ) => {
219+ const random = WebUtils . randomString ( ) ;
220+ const foo = WebUtils . randomString ( ) ;
221+ const paramObj = WebUtils . getUrlParams ( `https://app.example.com#random=${ random } &foo=${ foo } #hash` ) ;
222+ expect ( paramObj ! [ "random" ] ) . toStrictEqual ( random ) ;
223+ expect ( paramObj ! [ "foo" ] ) . toStrictEqual ( `${ foo } #hash` ) ;
224+ } ) ;
225+
205226 it ( 'should extract hash params correctly' , ( ) => {
206227 const random = WebUtils . randomString ( 20 ) ;
207228 const url = `http://localhost:4200/#state=${ random } &access_token=ya29.a0ARrdaM-sdfsfsdfsdfsdfs-YGFHwg_lM6dePPaT_TunbpsdfsdfsdfsEG6vTVLsLJDDW
@@ -213,6 +234,13 @@ describe("Url param extraction", () => {
213234 expect ( paramObj ! [ "prompt" ] ) . toBeDefined ( ) ;
214235 expect ( paramObj ! [ "state" ] ) . toStrictEqual ( random ) ;
215236 } ) ;
237+
238+ it ( 'should extract hash params if search param indicator present' , ( ) => {
239+ const token = "sldfskdjflsdf12302" ;
240+ const url = `http://localhost:3000/login?#access_token=${ token } ` ;
241+ const paramObj = WebUtils . getUrlParams ( url ) ;
242+ expect ( paramObj ! [ "access_token" ] ) . toStrictEqual ( token ) ;
243+ } )
216244} ) ;
217245
218246describe ( "Random string gen" , ( ) => {
0 commit comments