File tree Expand file tree Collapse file tree 2 files changed +25
-22
lines changed
app/code/Magento/CatalogSearch/view/frontend/web/js Expand file tree Collapse file tree 2 files changed +25
-22
lines changed Original file line number Diff line number Diff line change 44 */
55
66define ( [
7- 'jquery'
8- ] , function ( $ ) {
7+ 'jquery' ,
8+ 'mageUtils'
9+ ] , function ( $ , utils ) {
910 'use strict' ;
1011
11- /**
12- * Return url parameters.
13- * @returns {Object }
14- */
15- function urlParameters ( ) {
16- var params = { } ,
17- queries = window . location . search . substring ( 1 ) . split ( '&' ) ,
18- temp ,
19- i ,
20- l ;
21-
22- for ( i = 0 , l = queries . length ; i < l ; i ++ ) {
23- temp = queries [ i ] . split ( '=' ) ;
24- params [ temp [ 0 ] ] = temp [ 1 ] ;
25- }
26-
27- return params ;
28- }
29-
3012 return function ( data ) {
3113 $ . ajax ( {
3214 method : 'GET' ,
3315 url : data . url ,
3416 data : {
35- 'q' : decodeURIComponent ( urlParameters ( ) . q . replace ( / \+ / g , '%20' ) )
17+ 'q' : utils . getUrlParameters ( window . location . href ) . q
3618 }
3719 } ) ;
3820 } ;
Original file line number Diff line number Diff line change @@ -255,6 +255,27 @@ define([
255255 newFormat = newFormat . replace ( / d d | d / g, 'DD' ) ; // replace the date
256256
257257 return newFormat ;
258+ } ,
259+
260+ /**
261+ * Get Url Parameters.
262+ *
263+ * @param {String } url - Url string
264+ * @returns {Object }
265+ */
266+ getUrlParameters : function ( url ) {
267+ var params = { } ,
268+ queries = url . split ( '?' ) [ 1 ] . split ( '&' ) ,
269+ temp ,
270+ i ,
271+ l ;
272+
273+ for ( i = 0 , l = queries . length ; i < l ; i ++ ) {
274+ temp = queries [ i ] . split ( '=' ) ;
275+ params [ temp [ 0 ] ] = decodeURIComponent ( temp [ 1 ] . replace ( / \+ / g, '%20' ) ) ;
276+ }
277+
278+ return params ;
258279 }
259280 } ;
260281} ) ;
You can’t perform that action at this time.
0 commit comments