Authored by 陈峰

Merge branch 'hotfix/coupons' into 'gray'

Hotfix/coupons



See merge request !268
... ... @@ -10,7 +10,7 @@ const helpers = global.yoho.helpers;
const logger = global.yoho.logger;
const _ = require('lodash');
// const handleFilterUrl = require(`${global.utils}/parameter`).fullParamToMinPath;
const handleFilterUrl = require(`${global.utils}/parameter`).fullParamToMinPath;
// 搜索相关接口
const searchApi = require('../models/search-api');
... ... @@ -26,14 +26,14 @@ exports.index = (req, res, next) => {
let resData = {};
let qs = '';
// if (req.originalUrl && req.originalUrl.indexOf('.html') < 0 &&
// req.originalUrl.indexOf('?') < 0 && !_.isEmpty(req.query)) {
// let rUrl = handleFilterUrl('/list', req.query);
if (req.originalUrl &&
req.originalUrl.indexOf('.html') < 0 &&
req.originalUrl.indexOf('?') < 0 &&
req.yoho.seoParse) {
let rUrl = handleFilterUrl('/list', req.query);
// if (rUrl !== req.originalUrl) {
// return res.redirect(301, helpers.urlFormat(rUrl));
// }
// }
return res.redirect(301, helpers.urlFormat(rUrl));
}
try {
qs = decodeURIComponent(req._parsedOriginalUrl.query || '');
... ...
... ... @@ -8,7 +8,12 @@ module.exports = (req, res, next) => {
param = _.trimEnd(param, '.html');
if (param) {
Object.assign(req.query, parameter.minPathToFullParam(param));
const params = parameter.minPathToFullParam(param);
if (Object.keys(params).length) {
Object.assign(req.query, params);
req.yoho.seoParse = true;
}
}
next();
... ...