Authored by 周少峰

Merge branch 'hotfix/search-query-code-wrong' into 'master'

Hotfix/search query code wrong



See merge request !63
@@ -41,7 +41,8 @@ const handleFilterUrl = (originParam, newParam, delParam) => { @@ -41,7 +41,8 @@ const handleFilterUrl = (originParam, newParam, delParam) => {
41 41
42 _.forEach(tempOriginParam, function(value, key) { 42 _.forEach(tempOriginParam, function(value, key) {
43 if (!delParam[key] && value) { 43 if (!delParam[key] && value) {
44 - dest += `${key}=${value}&`; 44 + // NOTE: 这里会对 query 进行编码,因为 query 有可以能是中文
  45 + dest += key === 'query' ? `${key}=${encodeURIComponent(value)}&` : `${key}=${value}&`;
45 } 46 }
46 }); 47 });
47 48
@@ -1598,6 +1599,11 @@ exports.getSearchParams = params => { @@ -1598,6 +1599,11 @@ exports.getSearchParams = params => {
1598 nparams.price = nmp.join(','); 1599 nparams.price = nmp.join(',');
1599 } 1600 }
1600 1601
  1602 + // 对可能有中文的情况进行处理
  1603 + if (params.query) {
  1604 + params.query = decodeURIComponent(params.query);
  1605 + }
  1606 +
1601 return Object.assign({}, params, nparams); 1607 return Object.assign({}, params, nparams);
1602 }; 1608 };
1603 1609