Authored by htoooth

add doc

1 /** 1 /**
2 - * guang  
3 - * @author: lcy<chuanyang.liu@yoho.cn> 2 + * guang-伪静态处理修改
  3 + * example: http://guang.yohobuy.com/boys-t4-p2/
  4 + * 其中 p2 的意思为:page=2 第二页
  5 + * @author: huangtao
4 * @date: 2016/09/01 6 * @date: 2016/09/01
5 */ 7 */
6 8
1 /** 1 /**
2 * 后端:改写和跳转:中间件。 2 * 后端:改写和跳转:中间件。
  3 + *
  4 + * 说明:
  5 + * 该中间件使用:读该文件下的所以文件夹,以文件夹名的形式,载入该模块
  6 + * 文件夹的名字以网站子域名的形式存在,如:guang, item
  7 + * 每个文件夹是一个模块。
  8 + *
  9 + * 模块的导出形式:见 guang 模块的使用。
3 * Created by TaoHuang on 2017/2/21. 10 * Created by TaoHuang on 2017/2/21.
4 */ 11 */
5 12
@@ -5,13 +5,15 @@ @@ -5,13 +5,15 @@
5 5
6 const TYPE = require('../type'); 6 const TYPE = require('../type');
7 7
  8 +const MOBILE_DOMAIN = '//item.m.yohobuy.com';
  9 +
8 module.exports = [ 10 module.exports = [
9 // 商品详情页老链接 11 // 商品详情页老链接
10 { 12 {
11 type: TYPE.redirect, 13 type: TYPE.redirect,
12 origin: /^\/product\/pro_([\d]+)_([\d]+)\/(.*).html(.*)/, 14 origin: /^\/product\/pro_([\d]+)_([\d]+)\/(.*).html(.*)/,
13 target: (req, match, p1, p2, p3, p4) => { 15 target: (req, match, p1, p2, p3, p4) => {
14 - req.mobileUrl = `/product/pro_${p1}_1/1.html${p4}`; 16 + req.mobileUrl = `${MOBILE_DOMAIN}/product/pro_${p1}_1/1.html${p4}`;
15 return `/p${p1}.html${p4}`; 17 return `/p${p1}.html${p4}`;
16 } 18 }
17 }, 19 },
@@ -21,7 +23,7 @@ module.exports = [ @@ -21,7 +23,7 @@ module.exports = [
21 type: TYPE.rewrite, 23 type: TYPE.rewrite,
22 origin: /^\/p([\d]+).html(.*)/, 24 origin: /^\/p([\d]+).html(.*)/,
23 target: (req, match, p1, p2) => { 25 target: (req, match, p1, p2) => {
24 - req.mobileUrl = `/product/pro_${p1}_1/1.html${p2}`; 26 + req.mobileUrl = `${MOBILE_DOMAIN}/product/pro_${p1}_1/1.html${p2}`;
25 return `/product${req.url}`; 27 return `/product${req.url}`;
26 } 28 }
27 } 29 }