improve regex matching in challenge controller

This commit is contained in:
terakilobyte
2015-05-26 10:01:52 -04:00
parent 3078fa8104
commit 24f4648760

View File

@ -147,12 +147,12 @@ exports.returnCurrentChallenge = function(req, res, next) {
exports.returnIndividualChallenge = function(req, res, next) { exports.returnIndividualChallenge = function(req, res, next) {
var dashedName = req.params.challengeName; var dashedName = req.params.challengeName;
var challengeName = /^(bonfire|waypoint|zipline|basejump)/.test(dashedName) ? dashedName var challengeName = /^(bonfire|waypoint|zipline|basejump)/i.test(dashedName) ? dashedName
.replace(/\-/g, ' ') .replace(/\-/g, ' ')
.split(' ') .split(' ')
.slice(1) .slice(1)
.join(' ') .join(' ')
: dashedName; : dashedName.replace(/\-/g, ' ');
Challenge.find({'name': new RegExp(challengeName, 'i')}, Challenge.find({'name': new RegExp(challengeName, 'i')},
function(err, challengeFromMongo) { function(err, challengeFromMongo) {