factor out (un)dasherize into utils

This commit is contained in:
Berkeley Martinez
2015-06-22 17:24:55 -07:00
parent 10a5c3c928
commit d624cf3640
2 changed files with 15 additions and 12 deletions

View File

@@ -60,6 +60,17 @@ Array.zip = function(left, right, combinerFunction) {
module.exports = {
dasherize: function dasherize(name) {
return ('' + name)
.toLowerCase()
.replace(/\s/g, '-')
.replace(/[^a-z0-9\-\.]/gi, '');
},
unDasherize: function unDasherize(name) {
return ('' + name).replace(/\-/g, ' ');
},
getChallengeMapForDisplay: function () {
if (!challengeMapForDisplay) {
challengeMapForDisplay = {};