From 3a0dd2479f2d567519b85b5ff8a90d86d9087111 Mon Sep 17 00:00:00 2001 From: Anthony Kolber Date: Tue, 29 Apr 2014 22:16:37 +1000 Subject: [PATCH 1/2] Regular expression simplification, removes 4 lines --- viewloader.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/viewloader.js b/viewloader.js index a67acfc..ef18198 100644 --- a/viewloader.js +++ b/viewloader.js @@ -4,11 +4,7 @@ }(this, function(viewloader,$) { "use strict"; var dasherize = function(s) { - var r = /([a-z0-9][A-Z])/g, - dash = function(m) { - return m[0] + '-' + m[1].toLowerCase(); - }; - return s.replace(r, dash); + return s.replace(/([a-z0-9])([A-Z])/g, "$1-$2"); }; viewloader.execute = function(views, $scope) { for(var view in views) { From a95c00d4b5cd0bcd4786b24763b4bea4678037b6 Mon Sep 17 00:00:00 2001 From: Anthony Kolber Date: Tue, 29 Apr 2014 22:55:25 +1000 Subject: [PATCH 2/2] ... and lowercase it --- viewloader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/viewloader.js b/viewloader.js index ef18198..c8c29e0 100644 --- a/viewloader.js +++ b/viewloader.js @@ -4,7 +4,7 @@ }(this, function(viewloader,$) { "use strict"; var dasherize = function(s) { - return s.replace(/([a-z0-9])([A-Z])/g, "$1-$2"); + return s.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(); }; viewloader.execute = function(views, $scope) { for(var view in views) {