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(); 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) { if (dashedNameFull !== dashedName) {
return res.redirect('../news/' + dashedNameFull); return res.redirect('../news/' + dashedNameFull);
} }
@ -328,9 +330,6 @@ exports.storySubmission = function(req, res, next) {
return next(new Error('Not authorized')); return next(new Error('Not authorized'));
} }
var storyLink = data.headline var storyLink = data.headline
.replace(/\'/g, '')
.replace(/\"/g, '')
.replace(/,/g, '')
.replace(/\s+/g, ' ') .replace(/\s+/g, ' ')
.replace(/[^a-z0-9\s]/gi, '') .replace(/[^a-z0-9\s]/gi, '')
.toLowerCase() .toLowerCase()

View File

@ -18,8 +18,8 @@ function storyLinkCleanup(cb) {
console.log(i++); console.log(i++);
this.pause(); this.pause();
story.storyLink = story.storyLink. story.storyLink = story.storyLink.
replace(/[^a-z0-9\s]/gi, '').
replace(/\s+/g, ' '). replace(/\s+/g, ' ').
replace(/[^a-z0-9\s]/gi, '').
toLowerCase(). toLowerCase().
trim(); trim();
story.save(function (err) { story.save(function (err) {