re: #3043, if no address is entered, "http://" won't get automatically saved in

v1.18.x
Julian Lam 10 years ago
parent 5d495483ad
commit 5a0c657587

@ -122,18 +122,21 @@ module.exports = function(User) {
} else if (field === 'signature') {
data[field] = S(data[field]).stripTags().s;
} else if (field === 'website') {
var urlObj = url.parse(data[field], false, true);
if (!urlObj.protocol) {
urlObj.protocol = 'http';
urlObj.slashes = true;
}
if (!urlObj.hostname && urlObj.pathname) {
urlObj.hostname = urlObj.pathname;
urlObj.pathname = null;
}
if (urlObj.pathname === '/') {
urlObj.pathname = null;
if (data[field].length > 0) {
var urlObj = url.parse(data[field], false, true);
if (!urlObj.protocol) {
urlObj.protocol = 'http';
urlObj.slashes = true;
}
if (!urlObj.hostname && urlObj.pathname) {
urlObj.hostname = urlObj.pathname;
urlObj.pathname = null;
}
if (urlObj.pathname === '/') {
urlObj.pathname = null;
}
}
data[field] = url.format(urlObj);
}

Loading…
Cancel
Save