Showing
5 changed files
with
10 additions
and
23 deletions
@@ -151,7 +151,6 @@ const logger = global.yoho.logger; | @@ -151,7 +151,6 @@ const logger = global.yoho.logger; | ||
151 | try { | 151 | try { |
152 | const subDomain = require('./doraemon/middleware/sub-domain'); | 152 | const subDomain = require('./doraemon/middleware/sub-domain'); |
153 | const mobileRefer = require('./doraemon/middleware/mobile-refer'); | 153 | const mobileRefer = require('./doraemon/middleware/mobile-refer'); |
154 | - const itemNameHandler = require('./doraemon/middleware/item-name-handler'); | ||
155 | const mobileCheck = require('./doraemon/middleware/mobile-check'); | 154 | const mobileCheck = require('./doraemon/middleware/mobile-check'); |
156 | const user = require('./doraemon/middleware/user'); | 155 | const user = require('./doraemon/middleware/user'); |
157 | const seo = require('./doraemon/middleware/seo'); | 156 | const seo = require('./doraemon/middleware/seo'); |
@@ -165,7 +164,6 @@ try { | @@ -165,7 +164,6 @@ try { | ||
165 | // YOHO 前置中间件 | 164 | // YOHO 前置中间件 |
166 | app.use(subDomain()); | 165 | app.use(subDomain()); |
167 | app.use(mobileRefer()); | 166 | app.use(mobileRefer()); |
168 | - app.use(itemNameHandler); | ||
169 | app.use(mobileCheck()); | 167 | app.use(mobileCheck()); |
170 | app.use(setYohoData()); | 168 | app.use(setYohoData()); |
171 | app.use(user()); | 169 | app.use(user()); |
@@ -295,10 +295,6 @@ const getPackage = (req, res, next) => { | @@ -295,10 +295,6 @@ const getPackage = (req, res, next) => { | ||
295 | .catch(next); | 295 | .catch(next); |
296 | }; | 296 | }; |
297 | 297 | ||
298 | -const redirectNewProduct = (req, res) => { | ||
299 | - console.log(req.params); | ||
300 | - return res.status(301).redirect(helpers.urlFormat(`/p_${req.params[0]}/${req.params[2]}`, null, 'item')); | ||
301 | -}; | ||
302 | 298 | ||
303 | module.exports = { | 299 | module.exports = { |
304 | showMain, | 300 | showMain, |
@@ -311,6 +307,5 @@ module.exports = { | @@ -311,6 +307,5 @@ module.exports = { | ||
311 | recommend, | 307 | recommend, |
312 | getPackage, | 308 | getPackage, |
313 | likeConsult, | 309 | likeConsult, |
314 | - usefulConsult, | ||
315 | - redirectNewProduct | 310 | + usefulConsult |
316 | }; | 311 | }; |
@@ -62,7 +62,6 @@ router.get('/outlets/:channel', outlets.channel); // 奥莱频道页 | @@ -62,7 +62,6 @@ router.get('/outlets/:channel', outlets.channel); // 奥莱频道页 | ||
62 | 62 | ||
63 | // 商品分类列表页 | 63 | // 商品分类列表页 |
64 | router.get('/list', outletsList.index); | 64 | router.get('/list', outletsList.index); |
65 | -router.get(/\/pro_([\d]+)_([\d]+)\/(.*)/, detail.redirectNewProduct); | ||
66 | router.get(/\/p_([\d]+)(.*)/, detail.showMain); // 商品详情routers | 65 | router.get(/\/p_([\d]+)(.*)/, detail.showMain); // 商品详情routers |
67 | router.get('/detail/comment', detail.indexComment); // 商品评论 | 66 | router.get('/detail/comment', detail.indexComment); // 商品评论 |
68 | router.get('/detail/consult', detail.indexConsult); // 商品咨询 | 67 | router.get('/detail/consult', detail.indexConsult); // 商品咨询 |
1 | -/** | ||
2 | - * 商品详情页部分商品名称重置,防止express内部decodeURIComponent不能解析url出错 | ||
3 | - * @author: xuqi<qi.xu@yoho.cn> | ||
4 | - * @date: 2016/8/23 | ||
5 | - */ | ||
6 | - | ||
7 | -module.exports = function(req, res, next) { | ||
8 | - if (/^\/product\/pro_/.test(req.url)) { | ||
9 | - req.url = req.url.replace(/\/pro_([\d]+)_([\d]+)\/(.*)/, '/pro_$1_$2/yoho-replace.html'); | ||
10 | - } | ||
11 | - next(); | ||
12 | -}; |
@@ -24,9 +24,16 @@ module.exports = () => { | @@ -24,9 +24,16 @@ module.exports = () => { | ||
24 | case 'new': // 原新版 重定向到301 | 24 | case 'new': // 原新版 重定向到301 |
25 | return res.redirect(301, helpers.urlFormat(req.url, null, 'www')); | 25 | return res.redirect(301, helpers.urlFormat(req.url, null, 'www')); |
26 | case 'item':// 商品详情页 | 26 | case 'item':// 商品详情页 |
27 | - if (/\/p_([\d]+)(.*)/.exec(req.url) !== null) { | ||
28 | - req.url = `/product/p_${RegExp.$1}${RegExp.$2}`; | 27 | + if (/^\/p_/.test(req.url)) { // new |
28 | + req.url = `/product${req.url}`; | ||
29 | } | 29 | } |
30 | + | ||
31 | + if (/^\/product\/pro_/.test(req.url)) { // old | ||
32 | + return res.redirect(301, | ||
33 | + req.url.replace(/^\/product\/pro_([\d]+)_([\d]+)\/(.*).html(.*)/, '/p_$1.html$4') | ||
34 | + ); | ||
35 | + } | ||
36 | + | ||
30 | break; | 37 | break; |
31 | case 'guang': // 逛 | 38 | case 'guang': // 逛 |
32 | case 'cdnsrcguang': // 逛CDN回源解析 | 39 | case 'cdnsrcguang': // 逛CDN回源解析 |
-
Please register or login to post a comment