Authored by 姜枫

请求拦截新商品详情页url

@@ -11,7 +11,7 @@ let ONE_DAY = 60 * 60 * 24; @@ -11,7 +11,7 @@ let ONE_DAY = 60 * 60 * 24;
11 const MAX_QPS = config.maxQps; 11 const MAX_QPS = config.maxQps;
12 12
13 const PAGES = { 13 const PAGES = {
14 - '/product/\\/pro_([\\d]+)_([\\d]+)\\/(.*)/': 5, 14 + '/product/\\/p([\\d]+)(.*)/': 5,
15 '/product/list/index': 5 15 '/product/list/index': 5
16 }; 16 };
17 17
@@ -39,6 +39,8 @@ module.exports = (req, res, next) => { @@ -39,6 +39,8 @@ module.exports = (req, res, next) => {
39 remoteIp = arr[0]; 39 remoteIp = arr[0];
40 } 40 }
41 41
  42 + remoteIp = _.trim(remoteIp);
  43 +
42 if (remoteIp && 44 if (remoteIp &&
43 !_.get(req.app.locals, 'pc.sys.noLimiter') && 45 !_.get(req.app.locals, 'pc.sys.noLimiter') &&
44 !_.includes(IP_WHITE_LIST, remoteIp)) { // 判断获取remoteIp成功,并且开关未关闭 46 !_.includes(IP_WHITE_LIST, remoteIp)) { // 判断获取remoteIp成功,并且开关未关闭
@@ -56,6 +58,10 @@ module.exports = (req, res, next) => { @@ -56,6 +58,10 @@ module.exports = (req, res, next) => {
56 let pageKey = urlJoin(appPath, route.toString()); // route may be a regexp 58 let pageKey = urlJoin(appPath, route.toString()); // route may be a regexp
57 let pageIncr = PAGES[pageKey] || 0; 59 let pageIncr = PAGES[pageKey] || 0;
58 60
  61 + if (/^\/p([\d]+)/.test(req.path)) {
  62 + pageIncr = 5;
  63 + }
  64 +
59 if (pageIncr > 0) { 65 if (pageIncr > 0) {
60 cache.incrAsync(key, pageIncr); 66 cache.incrAsync(key, pageIncr);
61 } 67 }