Authored by 周少峰

Merge branch 'hotfix/error-refer'

... ... @@ -188,7 +188,7 @@ const local = {
if (/sign|login|reg|passport/.test(referUrl)) {
return `${config.siteUrl}/home`;
} else {
return decodeURI(req.cookies.refer);
return decodeURIComponent(req.cookies.refer);
}
} else {
return `${config.siteUrl}/home`;
... ...
... ... @@ -12,5 +12,5 @@ const config = global.yoho.config;
const allowedList = [/yohobuy\.com$/i, /yoho\.cn$/i];
module.exports = (refer) => {
return _.some(allowedList, allowed => allowed.test(url.parse(refer || config.siteUrl).hostname));
return _.some(allowedList, allowed => allowed.test(url.parse(refer || config.siteUrl, false, true).hostname));
};
... ...
{
"name": "yohobuy-node",
"version": "5.3.3",
"version": "5.3.5",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -180,11 +180,11 @@ function queryString() {
}());
function signinUrl() {
return '//www.yohobuy.com/signin.html?refer=' + window.location.href;
return '//www.yohobuy.com/signin.html?refer=' + encodeURIComponent(window.location.href);
}
function registerUrl() {
return '//www.yohobuy.com/reg.html?refer=' + window.location.href;
return '//www.yohobuy.com/reg.html?refer=' + encodeURIComponent(window.location.href);
}
function jumpUrl(url) {
... ...
... ... @@ -78,8 +78,9 @@ var bannerMap = {
},
cookieMap = {};
$('#signin-url').attr('href', '//www.yohobuy.com/signin.html?refer=' + window.location.href);
$('#reg-url').attr('href', '//www.yohobuy.com/reg.html?refer=' + window.location.href);
$('#signin-url').attr('href', window.signinUrl());
$('#reg-url').attr('href', window.registerUrl());
// handlebars模板
centerFn = handlebars.compile($('#simple-account-info-tpl').html() || '');
... ...
... ... @@ -1000,15 +1000,27 @@ function showCaptchaImgPic() {
$showCaptchImg = true;
}
function getReferForLogin() {
var vars = {},
hash,
index,
i,
search = window.location.search,
hashes = search ? search.slice(1).split('&') : [];
for (i = 0; i < hashes.length; i++) {
index = hashes[i].indexOf('=');
hash = hashes[i].substring(0, index);
vars[hash] = hashes[i].substring(++index);
}
return vars.refer || '';
}
// 设置 refer 信息
function setRefer() {
var refer = queryString().refer || '', // eslint-disable-line
var refer = getReferForLogin(),
regUrl;
if (refer) {
setCookie('refer', refer, {domain: '.yohobuy.com', path: '/'}); // eslint-disable-line
}
regUrl = (function() {
if (refer) {
return '/reg.html?refer=' + refer;
... ...