diff --git a/core/client/validators/user.js b/core/client/validators/user.js index 4f345b2500..7ab0f83a0d 100644 --- a/core/client/validators/user.js +++ b/core/client/validators/user.js @@ -51,7 +51,7 @@ var UserValidator = Ember.Object.create({ } if (!Ember.isEmpty(website) && - (!validator.isURL(website, {protocols: ['http', 'https'], require_protocol: true}) || + (!validator.isURL(website, {require_protocol: false}) || !validator.isLength(website, 0, 2000))) { validationErrors.push({message: 'Website is not a valid url'}); } diff --git a/core/server/models/user.js b/core/server/models/user.js index 0dd2f73fed..944a65fa68 100644 --- a/core/server/models/user.js +++ b/core/server/models/user.js @@ -94,6 +94,16 @@ User = ghostBookshelf.Model.extend({ return attrs; }, + format: function (options) { + if (!_.isEmpty(options.website) && + !validator.isURL(options.website, { + require_protocol: true, + protocols: ['http', 'https']})) { + options.website = 'http://' + options.website; + } + return options; + }, + posts: function () { return this.hasMany('Posts', 'created_by'); },