@@ -235,19 +235,54 @@ export function run() {
235
235
describe ( 'getQuerystring' , function ( ) {
236
236
it ( 'should have no entries for empty url' , ( ) => {
237
237
expect ( util . getQuerystring ( '' ) ) . toEqual ( { } ) ;
238
+ expect ( util . getQuerystring ( null ) ) . toEqual ( { } ) ;
239
+ expect ( util . getQuerystring ( undefined ) ) . toEqual ( { } ) ;
240
+ } ) ;
241
+
242
+ it ( 'should have no entries when without ?' , ( ) => {
243
+ expect ( util . getQuerystring ( 'http://localhost:1234/' ) ) . toEqual ( { } ) ;
244
+ } ) ;
245
+
246
+ it ( 'should have no entries with only ?' , ( ) => {
247
+ expect ( util . getQuerystring ( 'http://localhost:1234/?' ) ) . toEqual ( { } ) ;
248
+ } ) ;
249
+
250
+ it ( 'should have no entries for key with no =' , ( ) => {
251
+ expect ( util . getQuerystring ( 'http://localhost:1234/?key' ) ) . toEqual ( { } ) ;
252
+ } ) ;
253
+
254
+ it ( 'should have no entries with only #?' , ( ) => {
255
+ expect ( util . getQuerystring ( 'http://localhost:1234/#?' ) ) . toEqual ( { } ) ;
256
+ } ) ;
257
+
258
+ it ( 'should have no entries with only #?=' , ( ) => {
259
+ expect ( util . getQuerystring ( 'http://localhost:1234/#?=' ) ) . toEqual ( { } ) ;
238
260
} ) ;
239
261
240
262
it ( 'should have no entries for url with no "?" character' , ( ) => {
241
263
expect ( util . getQuerystring ( 'http://localhost:1234/#key1=1&key2=2' ) ) . toEqual ( { } ) ;
242
264
} ) ;
243
265
244
266
it ( 'should contain key/value entries for all the parameters after "?" character' , ( ) => {
245
- expect ( util . getQuerystring ( 'http://localhost:1234/#key0=0&key0x=0x?key1=1&key2=2' ) ) . toEqual ( {
267
+ expect ( util . getQuerystring ( 'http://localhost:1234/#key1=1&key2x=2x?key3=3&key4=4' ) ) . toEqual ( {
268
+ key3 : '3' ,
269
+ key4 : '4'
270
+ } ) ;
271
+ } ) ;
272
+
273
+ it ( 'should lowercase param keys' , ( ) => {
274
+ expect ( util . getQuerystring ( 'http://localhost:1234/#?KEY1=1&kEy2=2' ) ) . toEqual ( {
246
275
key1 : '1' ,
247
276
key2 : '2'
248
277
} ) ;
249
278
} ) ;
250
279
280
+ it ( 'should not include any values when # comes after ?' , ( ) => {
281
+ expect ( util . getQuerystring ( 'http://localhost:1234/?key1=1#key2=2' ) ) . toEqual ( {
282
+ key1 : '1'
283
+ } ) ;
284
+ } ) ;
285
+
251
286
it ( 'should ignore empty ?& and &&' , ( ) => {
252
287
expect ( util . getQuerystring ( 'http://localhost:1234/#?&&' ) ) . toEqual ( { } ) ;
253
288
@@ -257,6 +292,12 @@ export function run() {
257
292
} ) ;
258
293
} ) ;
259
294
295
+ it ( 'should get "" when key has no value' , ( ) => {
296
+ expect ( util . getQuerystring ( 'http://localhost:1234/#?key=' ) ) . toEqual ( {
297
+ key : ''
298
+ } ) ;
299
+ } ) ;
300
+
260
301
} ) ;
261
302
262
303
describe ( 'isTrueProperty' , function ( ) {
0 commit comments