Skip to content

Commit

Permalink
Improve Mibew.Utils.toDashFormat JS function
Browse files Browse the repository at this point in the history
  • Loading branch information
JustBlackBird committed Jan 21, 2015
1 parent e273b04 commit 6d3810b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/mibew/js/source/default/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,17 @@
if (typeof str != 'string') {
return false;
}
var parts = str.match(/((?:[A-Z]?[a-z]+)|(?:[A-Z][a-z]*))/g);

var parts = str.match(/((?:[A-Z]?[a-z0-9]+)|(?:[A-Z][a-z0-9]*))/g);
if (!parts) {
// It seems that the sting has no convertible parts.
return '';
}

for(var i = 0; i < parts.length; i++) {
parts[i] = parts[i].toLowerCase();
}

return parts.join('-');
}

Expand Down

0 comments on commit 6d3810b

Please sign in to comment.