Authored by 陈峰

Merge branch 'hotfix/cookie' into 'gray'

Hotfix/cookie



See merge request !188
@@ -10,7 +10,7 @@ const TYPE = require('../type'); @@ -10,7 +10,7 @@ const TYPE = require('../type');
10 module.exports = [ 10 module.exports = [
11 { 11 {
12 type: TYPE.redirect, 12 type: TYPE.redirect,
13 - origin: /\/about\?shopId=([\d]+)/, 13 + origin: /^\/about\?shopId=([\d]+)/,
14 target: (req, match, id) => { 14 target: (req, match, id) => {
15 return helpers.urlFormat(`/shop${id}-about`, null, req.subdomains[0]); 15 return helpers.urlFormat(`/shop${id}-about`, null, req.subdomains[0]);
16 } 16 }
@@ -139,7 +139,7 @@ module.exports = [ @@ -139,7 +139,7 @@ module.exports = [
139 }, 139 },
140 { 140 {
141 type: TYPE.rewrite, 141 type: TYPE.rewrite,
142 - origin: /\/(.*)-new/, 142 + origin: /^\/(.*)-new/,
143 target: (req, match, channel) => { 143 target: (req, match, channel) => {
144 return `/product/list/${channel}-new`; 144 return `/product/list/${channel}-new`;
145 } 145 }
@@ -102,7 +102,7 @@ module.exports = [ @@ -102,7 +102,7 @@ module.exports = [
102 // 新品到着 102 // 新品到着
103 { 103 {
104 type: TYPE.rewrite, 104 type: TYPE.rewrite,
105 - origin: /\/(.*)-new/, 105 + origin: /^\/(.*)-new/,
106 target: (req, match, channel) => { 106 target: (req, match, channel) => {
107 return `/product/list/${channel}-new`; 107 return `/product/list/${channel}-new`;
108 } 108 }
@@ -179,7 +179,7 @@ module.exports = [ @@ -179,7 +179,7 @@ module.exports = [
179 }, 179 },
180 { 180 {
181 type: TYPE.rewrite, 181 type: TYPE.rewrite,
182 - origin: /\/shop([\d]+)-about/, 182 + origin: /^\/shop([\d]+)-about/,
183 target: (req, match, id) => { 183 target: (req, match, id) => {
184 req.query.domain = req.subdomains[0]; 184 req.query.domain = req.subdomains[0];
185 req.query.shopId = id; 185 req.query.shopId = id;
@@ -45,7 +45,7 @@ var _gaq = _gaq || []; @@ -45,7 +45,7 @@ var _gaq = _gaq || [];
45 var s = document.getElementsByTagName("script")[0]; 45 var s = document.getElementsByTagName("script")[0];
46 s.parentNode.insertBefore(hm, s); 46 s.parentNode.insertBefore(hm, s);
47 47
48 - if (getUid() !== 0) { 48 + if (window.getUid && window.getUid() !== 0) {
49 _hmt.push(['_setCustomVar', 2, 'login', 'PC', 2]); 49 _hmt.push(['_setCustomVar', 2, 'login', 'PC', 2]);
50 } 50 }
51 })(); 51 })();
@@ -18,7 +18,11 @@ function cookie(name) { @@ -18,7 +18,11 @@ function cookie(name) {
18 var re = new RegExp(name + '=([^;$]*)', 'i'), 18 var re = new RegExp(name + '=([^;$]*)', 'i'),
19 matchPattern = '$1'; 19 matchPattern = '$1';
20 20
21 - return re.test(decodeURIComponent(document.cookie)) ? RegExp[matchPattern] : ''; 21 + try {
  22 + return re.test(decodeURIComponent(document.cookie)) ? RegExp[matchPattern] : '';
  23 + } catch (e) {
  24 + return decodeURIComponent(re.test(document.cookie) ? RegExp[matchPattern] : '');
  25 + }
22 } 26 }
23 27
24 function setCookie(name, value, options) { 28 function setCookie(name, value, options) {
@@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
7 'use strict'; 7 'use strict';
8 8
9 const _ = require('lodash'); 9 const _ = require('lodash');
  10 +
10 // const logger = global.yoho.logger; 11 // const logger = global.yoho.logger;
11 const queryString = require('querystring'); 12 const queryString = require('querystring');
12 13
@@ -57,6 +58,7 @@ const transformKey = (params, isFull) => { @@ -57,6 +58,7 @@ const transformKey = (params, isFull) => {
57 matchParams[name] = value; 58 matchParams[name] = value;
58 } else { 59 } else {
59 extraParams[key] = value; 60 extraParams[key] = value;
  61 +
60 // logger.info(`list parameter [${key}] map value not found`); 62 // logger.info(`list parameter [${key}] map value not found`);
61 } 63 }
62 }); 64 });