File tree Expand file tree Collapse file tree 2 files changed +34
-5
lines changed
dev/tests/js/jasmine/tests/lib/mage Expand file tree Collapse file tree 2 files changed +34
-5
lines changed Original file line number Diff line number Diff line change @@ -12,13 +12,37 @@ define([
12
12
describe ( 'mageUtils' , function ( ) {
13
13
14
14
it ( 'Check getUrlParameters function' , function ( ) {
15
- var url = 'http://example.com/catalogsearch/result/?q=+Simple+99%2C+8%2F%3F&cat=3' ,
16
- urlParameters = {
15
+ var fixture ,
16
+ url ,
17
+ getParameters ;
18
+
19
+ fixture = {
20
+ 'not valid url' : { } ,
21
+ 'http://example.com/catalogsearch/result/' : { } ,
22
+ 'http://example.com/catalogsearch/result/?' : { } ,
23
+ 'http://example.com/catalogsearch/result/?q' : {
24
+ q : ''
25
+ } ,
26
+ 'http://example.com/catalogsearch/result/?q=' : {
27
+ q : ''
28
+ } ,
29
+ 'http://example.com/catalogsearch/result/?q=+Simple+99%2C+8%2F%3F&cat=3' : {
17
30
q : ' Simple 99, 8/?' ,
18
31
cat : '3'
19
- } ;
32
+ } ,
33
+ 'http://example.com/catalogsearch/result/?q=Simple&cat=3&p=1' : {
34
+ q : 'Simple' ,
35
+ cat : '3' ,
36
+ p : '1'
37
+ }
38
+ } ;
20
39
21
- expect ( utils . getUrlParameters ( url ) ) . toEqual ( urlParameters ) ;
40
+ for ( url in fixture ) {
41
+ if ( fixture . hasOwnProperty ( url ) ) {
42
+ getParameters = fixture [ url ] ;
43
+ expect ( utils . getUrlParameters ( url ) ) . toEqual ( getParameters ) ;
44
+ }
45
+ }
22
46
} ) ;
23
47
24
48
it ( 'Check convertToMomentFormat function' , function ( ) {
Original file line number Diff line number Diff line change @@ -272,9 +272,14 @@ define([
272
272
273
273
if ( queries [ 1 ] ) {
274
274
queries = queries [ 1 ] . split ( '&' ) ;
275
+
275
276
for ( i = 0 , l = queries . length ; i < l ; i ++ ) {
276
277
temp = queries [ i ] . split ( '=' ) ;
277
- params [ temp [ 0 ] ] = decodeURIComponent ( temp [ 1 ] . replace ( / \+ / g, '%20' ) ) ;
278
+ if ( temp [ 1 ] ) {
279
+ params [ temp [ 0 ] ] = decodeURIComponent ( temp [ 1 ] . replace ( / \+ / g, '%20' ) ) ;
280
+ } else {
281
+ params [ temp [ 0 ] ] = '' ;
282
+ }
278
283
}
279
284
}
280
285
You can’t perform that action at this time.
0 commit comments