Consisten dasherization in stories. Updated story cleanup script.

This commit is contained in:
terakilobyte
2015-05-25 23:27:21 -04:00
parent 406f4d17e5
commit c74a8a7fc0
2 changed files with 4 additions and 5 deletions

View File

@ -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()

View File

@ -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) {