From 8c803281f65ce006179b8574a6630b372b09302e Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Tue, 18 Aug 2015 19:23:43 -0700 Subject: [PATCH] fix cannot read property match of undefined --- server/boot/challenge.js | 6 +++--- server/boot/user.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server/boot/challenge.js b/server/boot/challenge.js index 54c28c983c..fc17828f2a 100644 --- a/server/boot/challenge.js +++ b/server/boot/challenge.js @@ -320,7 +320,7 @@ module.exports = function(app) { var challengeData = { id: challengeId, - name: req.body.challengeInfo.challengeName, + name: req.body.challengeInfo.challengeName || '', completedDate: Math.round(+new Date()), solution: req.body.challengeInfo.solution, challengeType: 5 @@ -399,7 +399,7 @@ module.exports = function(app) { { id: id || challengeId, completedDate: completedDate, - name: name || challengeName, + name: name || challengeName || '', solution: null, githubLink: null, verified: true @@ -446,7 +446,7 @@ module.exports = function(app) { var challengeData = { id: challengeId, - name: req.body.challengeInfo.challengeName, + name: req.body.challengeInfo.challengeName || '', completedDate: completedDate, solution: solutionLink, githubLink: githubLink, diff --git a/server/boot/user.js b/server/boot/user.js index 1ed1381240..be063d47e1 100644 --- a/server/boot/user.js +++ b/server/boot/user.js @@ -156,7 +156,7 @@ module.exports = function(app) { }); const bonfires = user.completedChallenges.filter(function(obj) { - return obj.challengeType === 5 && obj.name.match(/Bonfire/g); + return obj.challengeType === 5 && (obj.name || '').match(/Bonfire/g); }); res.render('account/show', {