From c4a92855088a0a22341d7972bad26ee2139b7960 Mon Sep 17 00:00:00 2001 From: terakilobyte Date: Sun, 31 May 2015 18:43:11 -0400 Subject: [PATCH] Fix dasherization for stories, closes #648 --- controllers/story.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/controllers/story.js b/controllers/story.js index 3a34c7b883..4911409861 100755 --- a/controllers/story.js +++ b/controllers/story.js @@ -330,8 +330,8 @@ exports.storySubmission = function(req, res, next) { return next(new Error('Not authorized')); } var storyLink = data.headline - .replace(/\s+/g, ' ') .replace(/[^a-z0-9\s]/gi, '') + .replace(/\s+/g, ' ') .toLowerCase() .trim(); var link = data.link; @@ -346,6 +346,8 @@ exports.storySubmission = function(req, res, next) { // if duplicate storyLink add unique number storyLink = (storyCount === 0) ? storyLink : storyLink + ' ' + storyCount; + debug(storyLink); + var link = data.link; if (link.search(/^https?:\/\//g) === -1) { link = 'http://' + link; @@ -389,7 +391,7 @@ exports.storySubmission = function(req, res, next) { } }); res.send(JSON.stringify({ - storyLink: story.storyLink.replace(/\s/g, '-').toLowerCase() + storyLink: story.storyLink.replace(/\s+/g, '-').toLowerCase() })); }); });