diff --git a/controllers/story.js b/controllers/story.js index 233f929b69..3a34c7b883 100755 --- a/controllers/story.js +++ b/controllers/story.js @@ -137,7 +137,9 @@ exports.returnIndividualStory = function(req, res, next) { } story = story.pop(); - var dashedNameFull = story.storyLink.toLowerCase().replace(/\s/g, '-'); + var dashedNameFull = story.storyLink.toLowerCase() + .replace(/\s+/g, ' ') + .replace(/\s/g, '-'); if (dashedNameFull !== dashedName) { return res.redirect('../news/' + dashedNameFull); } @@ -328,9 +330,6 @@ exports.storySubmission = function(req, res, next) { return next(new Error('Not authorized')); } var storyLink = data.headline - .replace(/\'/g, '') - .replace(/\"/g, '') - .replace(/,/g, '') .replace(/\s+/g, ' ') .replace(/[^a-z0-9\s]/gi, '') .toLowerCase() diff --git a/seed_data/storyCleanup.js b/seed_data/storyCleanup.js index 2598526c8a..c216e67293 100644 --- a/seed_data/storyCleanup.js +++ b/seed_data/storyCleanup.js @@ -18,8 +18,8 @@ function storyLinkCleanup(cb) { console.log(i++); this.pause(); story.storyLink = story.storyLink. - replace(/[^a-z0-9\s]/gi, ''). replace(/\s+/g, ' '). + replace(/[^a-z0-9\s]/gi, ''). toLowerCase(). trim(); story.save(function (err) {