Fix dasherization for stories, closes #648
This commit is contained in:
@ -330,8 +330,8 @@ 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(/\s+/g, ' ')
|
|
||||||
.replace(/[^a-z0-9\s]/gi, '')
|
.replace(/[^a-z0-9\s]/gi, '')
|
||||||
|
.replace(/\s+/g, ' ')
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.trim();
|
.trim();
|
||||||
var link = data.link;
|
var link = data.link;
|
||||||
@ -346,6 +346,8 @@ exports.storySubmission = function(req, res, next) {
|
|||||||
// if duplicate storyLink add unique number
|
// if duplicate storyLink add unique number
|
||||||
storyLink = (storyCount === 0) ? storyLink : storyLink + ' ' + storyCount;
|
storyLink = (storyCount === 0) ? storyLink : storyLink + ' ' + storyCount;
|
||||||
|
|
||||||
|
debug(storyLink);
|
||||||
|
|
||||||
var link = data.link;
|
var link = data.link;
|
||||||
if (link.search(/^https?:\/\//g) === -1) {
|
if (link.search(/^https?:\/\//g) === -1) {
|
||||||
link = 'http://' + link;
|
link = 'http://' + link;
|
||||||
@ -389,7 +391,7 @@ exports.storySubmission = function(req, res, next) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
res.send(JSON.stringify({
|
res.send(JSON.stringify({
|
||||||
storyLink: story.storyLink.replace(/\s/g, '-').toLowerCase()
|
storyLink: story.storyLink.replace(/\s+/g, '-').toLowerCase()
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user