Skip to content

Commit f3b7f42

Browse files
authored
Merge pull request #56 from rahulcs/avoid-decoding-when-noEncoding-true
feat: avoid decoding when `noEncoding` true
2 parents 6bd286d + 467c5b8 commit f3b7f42

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

unbxdSearch.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//uglifyjs unbxdSearch.js -o unbxdSearch.min.js && gzip -c unbxdSearch.min.js > unbxdSearch.min.js.gz && aws s3 cp unbxdSearch.min.js.gz s3://unbxd/unbxdSearch.js --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-encoding gzip --cache-control max-age=3600
22
var unbxdSearchInit = function(jQuery, Handlebars){
33
window.Unbxd = window.Unbxd || {};
4-
Unbxd.jsSdkVersion = "2.0.1";
4+
Unbxd.jsSdkVersion = "2.0.2";
55

66
// Production steps of ECMA-262, Edition 5, 15.4.4.14
77
// Reference: http://es5.github.io/#x15.4.4.14
@@ -557,16 +557,16 @@ var unbxdSearchInit = function(jQuery, Handlebars){
557557
this.reset();
558558

559559
var cur_url = this.getUrlSubstring()
560-
,urlqueryparams = this.getQueryParams(cur_url)
561-
// add test to check if the url is encoded,
562-
// decode the query parameters only if url is encoded
563-
// fixes SKU searches like writ0035/WRIT0035 & HSWD0015
564-
,decodedParams = !(/[^A-Za-z0-9\+\/\=]/g.test(cur_url)) ? this.getQueryParams(this.decode(cur_url)) : {}
565-
,queryparamcount = Object.keys(urlqueryparams).length
566-
,decodedParamscount = Object.keys(decodedParams).length
567-
,finalParams = null;
568-
569-
if(!this.options.noEncoding && decodedParamscount > 0){
560+
, urlqueryparams = this.getQueryParams(cur_url)
561+
// add test to check if the url is encoded,
562+
// decode the query parameters only if url is encoded
563+
// fixes SKU searches like writ0035/WRIT0035 & HSWD0015
564+
, decodedParams = !(this.options.noEncoding && /[^A-Za-z0-9\+\/\=]/g.test(cur_url)) ? this.getQueryParams(this.decode(cur_url)) : {}
565+
, queryparamcount = Object.keys(urlqueryparams).length
566+
, decodedParamscount = Object.keys(decodedParams).length
567+
, finalParams = null;
568+
569+
if (!this.options.noEncoding && decodedParamscount > 0) {
570570
finalParams = this._processURL(decodedParams);
571571
}else{
572572
finalParams = this._processURL(urlqueryparams);

0 commit comments

Comments
 (0)