From 783d7cf1ec123144fdd26130cdfa846ef485d9a9 Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Thu, 6 Aug 2015 15:37:07 -0700 Subject: [PATCH] fix string non-alphanumeric non-whitespace chars before regex --- server/utils/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/utils/index.js b/server/utils/index.js index 72d515dd5f..784aa71366 100644 --- a/server/utils/index.js +++ b/server/utils/index.js @@ -62,7 +62,12 @@ module.exports = { }, unDasherize: function unDasherize(name) { - return ('' + name).replace(/\-/g, ' ').trim(); + return ('' + name) + // replace dash with space + .replace(/\-/g, ' ') + // strip nonalphanumarics chars except whitespace + .replace(/[^a-zA-Z\d\s]/g, '') + .trim(); }, getChallengeMapForDisplay: function() {