mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-04-08 02:52:39 -05:00
Deduplicate upper-/lowercase tags for posts
server side check for #2478 - added check for duplicate tags in post model
This commit is contained in:
parent
09b8eaf5ad
commit
a3aba2d504
1 changed files with 14 additions and 3 deletions
|
@ -48,10 +48,21 @@ Post = ghostBookshelf.Model.extend({
|
|||
|
||||
saving: function (newPage, attr, options) {
|
||||
/*jshint unused:false*/
|
||||
var self = this;
|
||||
var self = this,
|
||||
tagsToCheck,
|
||||
i;
|
||||
|
||||
// keep tags for 'saved' event
|
||||
this.myTags = this.get('tags');
|
||||
// keep tags for 'saved' event and deduplicate upper/lowercase tags
|
||||
tagsToCheck = this.get('tags');
|
||||
this.myTags = [];
|
||||
_.each(tagsToCheck, function (item) {
|
||||
for (i = 0; i < self.myTags.length; i = i + 1) {
|
||||
if (self.myTags[i].name.toLocaleLowerCase() === item.name.toLocaleLowerCase()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
self.myTags.push(item);
|
||||
});
|
||||
|
||||
ghostBookshelf.Model.prototype.saving.call(this);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue