Merge branch 'hotfix/error-refer'
Showing
6 changed files
with
25 additions
and
12 deletions
@@ -188,7 +188,7 @@ const local = { | @@ -188,7 +188,7 @@ const local = { | ||
188 | if (/sign|login|reg|passport/.test(referUrl)) { | 188 | if (/sign|login|reg|passport/.test(referUrl)) { |
189 | return `${config.siteUrl}/home`; | 189 | return `${config.siteUrl}/home`; |
190 | } else { | 190 | } else { |
191 | - return decodeURI(req.cookies.refer); | 191 | + return decodeURIComponent(req.cookies.refer); |
192 | } | 192 | } |
193 | } else { | 193 | } else { |
194 | return `${config.siteUrl}/home`; | 194 | return `${config.siteUrl}/home`; |
@@ -12,5 +12,5 @@ const config = global.yoho.config; | @@ -12,5 +12,5 @@ const config = global.yoho.config; | ||
12 | const allowedList = [/yohobuy\.com$/i, /yoho\.cn$/i]; | 12 | const allowedList = [/yohobuy\.com$/i, /yoho\.cn$/i]; |
13 | 13 | ||
14 | module.exports = (refer) => { | 14 | module.exports = (refer) => { |
15 | - return _.some(allowedList, allowed => allowed.test(url.parse(refer || config.siteUrl).hostname)); | 15 | + return _.some(allowedList, allowed => allowed.test(url.parse(refer || config.siteUrl, false, true).hostname)); |
16 | }; | 16 | }; |
@@ -180,11 +180,11 @@ function queryString() { | @@ -180,11 +180,11 @@ function queryString() { | ||
180 | }()); | 180 | }()); |
181 | 181 | ||
182 | function signinUrl() { | 182 | function signinUrl() { |
183 | - return '//www.yohobuy.com/signin.html?refer=' + window.location.href; | 183 | + return '//www.yohobuy.com/signin.html?refer=' + encodeURIComponent(window.location.href); |
184 | } | 184 | } |
185 | 185 | ||
186 | function registerUrl() { | 186 | function registerUrl() { |
187 | - return '//www.yohobuy.com/reg.html?refer=' + window.location.href; | 187 | + return '//www.yohobuy.com/reg.html?refer=' + encodeURIComponent(window.location.href); |
188 | } | 188 | } |
189 | 189 | ||
190 | function jumpUrl(url) { | 190 | function jumpUrl(url) { |
@@ -78,8 +78,9 @@ var bannerMap = { | @@ -78,8 +78,9 @@ var bannerMap = { | ||
78 | }, | 78 | }, |
79 | cookieMap = {}; | 79 | cookieMap = {}; |
80 | 80 | ||
81 | -$('#signin-url').attr('href', '//www.yohobuy.com/signin.html?refer=' + window.location.href); | ||
82 | -$('#reg-url').attr('href', '//www.yohobuy.com/reg.html?refer=' + window.location.href); | 81 | +$('#signin-url').attr('href', window.signinUrl()); |
82 | +$('#reg-url').attr('href', window.registerUrl()); | ||
83 | + | ||
83 | 84 | ||
84 | // handlebars模板 | 85 | // handlebars模板 |
85 | centerFn = handlebars.compile($('#simple-account-info-tpl').html() || ''); | 86 | centerFn = handlebars.compile($('#simple-account-info-tpl').html() || ''); |
@@ -1000,15 +1000,27 @@ function showCaptchaImgPic() { | @@ -1000,15 +1000,27 @@ function showCaptchaImgPic() { | ||
1000 | $showCaptchImg = true; | 1000 | $showCaptchImg = true; |
1001 | } | 1001 | } |
1002 | 1002 | ||
1003 | +function getReferForLogin() { | ||
1004 | + var vars = {}, | ||
1005 | + hash, | ||
1006 | + index, | ||
1007 | + i, | ||
1008 | + search = window.location.search, | ||
1009 | + hashes = search ? search.slice(1).split('&') : []; | ||
1010 | + | ||
1011 | + for (i = 0; i < hashes.length; i++) { | ||
1012 | + index = hashes[i].indexOf('='); | ||
1013 | + hash = hashes[i].substring(0, index); | ||
1014 | + vars[hash] = hashes[i].substring(++index); | ||
1015 | + } | ||
1016 | + return vars.refer || ''; | ||
1017 | +} | ||
1018 | + | ||
1003 | // 设置 refer 信息 | 1019 | // 设置 refer 信息 |
1004 | function setRefer() { | 1020 | function setRefer() { |
1005 | - var refer = queryString().refer || '', // eslint-disable-line | 1021 | + var refer = getReferForLogin(), |
1006 | regUrl; | 1022 | regUrl; |
1007 | 1023 | ||
1008 | - if (refer) { | ||
1009 | - setCookie('refer', refer, {domain: '.yohobuy.com', path: '/'}); // eslint-disable-line | ||
1010 | - } | ||
1011 | - | ||
1012 | regUrl = (function() { | 1024 | regUrl = (function() { |
1013 | if (refer) { | 1025 | if (refer) { |
1014 | return '/reg.html?refer=' + refer; | 1026 | return '/reg.html?refer=' + refer; |
-
Please register or login to post a comment