mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
Merge pull request #4466 from VictorVation/url-validation
Improve validation for user.website
This commit is contained in:
commit
1079ef8aeb
2 changed files with 11 additions and 1 deletions
|
@ -51,7 +51,7 @@ var UserValidator = Ember.Object.create({
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Ember.isEmpty(website) &&
|
if (!Ember.isEmpty(website) &&
|
||||||
(!validator.isURL(website, {protocols: ['http', 'https'], require_protocol: true}) ||
|
(!validator.isURL(website, {require_protocol: false}) ||
|
||||||
!validator.isLength(website, 0, 2000))) {
|
!validator.isLength(website, 0, 2000))) {
|
||||||
validationErrors.push({message: 'Website is not a valid url'});
|
validationErrors.push({message: 'Website is not a valid url'});
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,16 @@ User = ghostBookshelf.Model.extend({
|
||||||
return attrs;
|
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 () {
|
posts: function () {
|
||||||
return this.hasMany('Posts', 'created_by');
|
return this.hasMany('Posts', 'created_by');
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue