From e2cf2a2fe7bd7d5c66abe33296b5a21920df17bd Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Sat, 29 Apr 2017 14:43:43 -0700 Subject: [PATCH] Remove periods from url slugs. Fixes #15 --- server/models/Document.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/models/Document.js b/server/models/Document.js index b20a98b30..4e6e165e7 100644 --- a/server/models/Document.js +++ b/server/models/Document.js @@ -8,6 +8,10 @@ import User from './User'; import Revision from './Revision'; slug.defaults.mode = 'rfc3986'; +const slugify = text => + slug(text, { + remove: /[.]/g, + }); const createRevision = async doc => { // Create revision of the current (latest) @@ -25,7 +29,7 @@ const documentBeforeSave = async doc => { doc.html = convertToMarkdown(doc.text); doc.preview = truncateMarkdown(doc.text, 160); - doc.revisionCount = doc.revisionCount + 1; + doc.revisionCount += 1; // Collaborators let ids = []; @@ -91,7 +95,7 @@ const Document = sequelize.define( }, instanceMethods: { getUrl() { - const slugifiedTitle = slug(this.title); + const slugifiedTitle = slugify(this.title); return `/d/${slugifiedTitle}-${this.urlId}`; }, },