Authored by yyq

Merge branch 'hotfix/searchHistory' into release/6.4

... ... @@ -154,6 +154,8 @@ exports.special = (req, res, next) => {
let specialId = params.specialsale_id || params.specialsaleId, // 专区ID
promotion = params.promotion; // 促销ID
specialId = parseInt(`0${specialId}`, 10);
if (!specialId && !promotion) {
return next();
}
... ...
... ... @@ -142,7 +142,13 @@ const searchFilterBrands = (req, res, next) => {
const searchHistory = (req, res) => {
let history = req.cookies['_History'] || ''; //eslint-disable-line
let q = req.query.query ? _.trim(decodeURIComponent(req.query.query)) : '';
let q = _.trim(req.query.query || '');
try {
q = decodeURIComponent(q);
} catch (e) { //eslint-disable-line
q = '';
}
history = _.filter(history.split(','), old => old && old !== q);
... ...
... ... @@ -268,8 +268,10 @@ function getBrands4Filter(params) {
delete params.callback;
}
if (params.specialsale_id) {
return this.saleApi.getSaleSpecialAsync(params.specialsale_id).then(special => {
const specialId = parseInt(`0${params.specialsale_id || ''}`, 10);
if (specialId) {
return this.saleApi.getSaleSpecialAsync(specialId).then(special => {
if (special && special.data) {
let data = special.data;
... ...
... ... @@ -3,14 +3,12 @@
const urlEncode = require('urlencode');
const _ = require('lodash');
const helpers = global.yoho.helpers;
const allowSubDomain = ['list', 'search'];
module.exports = (req, res, next) => {
let query = req.query.query;
let query = _.trim(req.query.query);
let subDomain = req.subdomains[0];
if (query && _.includes(allowSubDomain, subDomain)) {
if (query) {
try {
decodeURIComponent(query);
return next();
... ...