Stopped characters with poor names from having failed URL's

This commit is contained in:
Stefan Zermatten
2017-07-13 17:16:23 +02:00
parent a411fb2b43
commit ac23afac5d
5 changed files with 10 additions and 4 deletions

View File

@@ -4,7 +4,7 @@ Characters = new Mongo.Collection("characters");
Schemas.Character = new SimpleSchema({
//strings
name: {type: String, defaultValue: "", trim: false, optional: true},
urlName: {type: String, defaultValue: "", trim: false, optional: true},
urlName: {type: String, defaultValue: "-", trim: false, optional: true},
alignment: {type: String, defaultValue: "", trim: false, optional: true},
gender: {type: String, defaultValue: "", trim: false, optional: true},
race: {type: String, defaultValue: "", trim: false, optional: true},
@@ -547,6 +547,9 @@ if (Meteor.isServer){
Characters.update(doc._id, {$set: {urlName}});
}
});
Characters.before.insert(function(userId, doc) {
doc.urlName = getSlug(doc.name, {maintainCase: true}) || "-";
});
}
Characters.allow({