Skip to content

Commit

Permalink
Fix escaping in regular expressions.
Browse files Browse the repository at this point in the history
  • Loading branch information
sgress454 committed May 4, 2015
1 parent 71f96b8 commit 0486dd8
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions lib/hooks/moduleloader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,11 @@ module.exports = function(sails) {
async.auto({

'config/*': function loadOtherConfigFiles (cb) {
// console.log('TRYING T LOAD CONFIG AT:',sails.config.paths.config);
buildDictionary.aggregate({
dirname : sails.config.paths.config || sails.config.appPath + '/config',
exclude : ['locales'].concat(_.map(sails.config.moduleloader.configExt, function(item){ return 'local.'+item; })),
excludeDirs: /(locales|env)$/,
filter : new RegExp("(.+)\.(" + sails.config.moduleloader.configExt.join('|') + ")$"),
filter : new RegExp("(.+)\\.(" + sails.config.moduleloader.configExt.join('|') + ")$"),
flattenDirectories: !(sails.config.dontFlattenConfig),
identity : false
}, cb);
Expand All @@ -237,7 +236,7 @@ module.exports = function(sails) {
'config/local' : function loadLocalOverrideFile (cb) {
buildDictionary.aggregate({
dirname : sails.config.paths.config || sails.config.appPath + '/config',
filter : new RegExp("local\.(" + sails.config.moduleloader.configExt.join('|') + ")$"),
filter : new RegExp("local\\.(" + sails.config.moduleloader.configExt.join('|') + ")$"),
identity : false
}, cb);
},
Expand All @@ -250,7 +249,7 @@ module.exports = function(sails) {
var env = sails.config.environment || async_data['config/local'].environment || 'development';
buildDictionary.aggregate({
dirname : (sails.config.paths.config || sails.config.appPath + '/config') + '/env/' + env,
filter : new RegExp("(.+)\.(" + sails.config.moduleloader.configExt.join('|') + ")$"),
filter : new RegExp("(.+)\\.(" + sails.config.moduleloader.configExt.join('|') + ")$"),
optional : true,
flattenDirectories: !(sails.config.dontFlattenConfig),
identity : false
Expand Down Expand Up @@ -302,7 +301,7 @@ module.exports = function(sails) {
loadControllers: function (cb) {
buildDictionary.optional({
dirname: sails.config.paths.controllers,
filter: new RegExp("(.+)Controller\.(" + sails.config.moduleloader.sourceExt.join('|') + ")$"),
filter: new RegExp("(.+)Controller\\.(" + sails.config.moduleloader.sourceExt.join('|') + ")$"),
flattenDirectories: true,
keepDirectoryPath: true,
replaceExpr: /Controller/
Expand All @@ -321,7 +320,7 @@ module.exports = function(sails) {
loadAdapters: function (cb) {
buildDictionary.optional({
dirname: sails.config.paths.adapters,
filter: new RegExp("(.+Adapter)\.(" + sails.config.moduleloader.sourceExt.join('|') + ")$"),
filter: new RegExp("(.+Adapter)\\.(" + sails.config.moduleloader.sourceExt.join('|') + ")$"),
replaceExpr: /Adapter/,
flattenDirectories: true
}, bindToSails(cb));
Expand All @@ -340,7 +339,7 @@ module.exports = function(sails) {
// Get the main model files
buildDictionary.optional({
dirname : sails.config.paths.models,
filter : new RegExp("^([^.]+)\.(" + sails.config.moduleloader.sourceExt.join('|') + ")$"),
filter : new RegExp("^([^.]+)\\.(" + sails.config.moduleloader.sourceExt.join('|') + ")$"),
replaceExpr : /^.*\//,
flattenDirectories: true
}, function(err, models) {
Expand Down Expand Up @@ -371,7 +370,7 @@ module.exports = function(sails) {
loadServices: function (cb) {
buildDictionary.optional({
dirname : sails.config.paths.services,
filter : new RegExp("(.+)\.(" + sails.config.moduleloader.sourceExt.join('|') + ")$"),
filter : new RegExp("(.+)\\.(" + sails.config.moduleloader.sourceExt.join('|') + ")$"),
depth : 1,
caseSensitive : true
}, bindToSails(cb));
Expand Down Expand Up @@ -405,7 +404,7 @@ module.exports = function(sails) {
loadPolicies: function (cb) {
buildDictionary.optional({
dirname: sails.config.paths.policies,
filter: new RegExp("(.+)\.(" + sails.config.moduleloader.sourceExt.join('|') + ")$"),
filter: new RegExp("(.+)\\.(" + sails.config.moduleloader.sourceExt.join('|') + ")$"),
replaceExpr: null,
flattenDirectories: true,
keepDirectoryPath: true
Expand All @@ -427,7 +426,7 @@ module.exports = function(sails) {
hooksFolder: function(cb) {
buildDictionary.optional({
dirname: sails.config.paths.hooks,
filter: new RegExp("^(.+)\.(" + sails.config.moduleloader.sourceExt.join('|') + ")$"),
filter: new RegExp("^(.+)\\.(" + sails.config.moduleloader.sourceExt.join('|') + ")$"),

// Hooks should be defined as either single files as a function
// OR (better yet) a subfolder with an index.js file
Expand Down Expand Up @@ -521,7 +520,7 @@ module.exports = function(sails) {
loadBlueprints: function (cb) {
buildDictionary.optional({
dirname: sails.config.paths.blueprints,
filter: new RegExp("(.+)\.(" + sails.config.moduleloader.sourceExt.join('|') + ")$"),
filter: new RegExp("(.+)\\.(" + sails.config.moduleloader.sourceExt.join('|') + ")$"),
useGlobalIdForKeyName: true
}, cb);
},
Expand All @@ -537,7 +536,7 @@ module.exports = function(sails) {
loadResponses: function (cb) {
buildDictionary.optional({
dirname: sails.config.paths.responses,
filter: new RegExp("(.+)\.(" + sails.config.moduleloader.sourceExt.join('|') + ")$"),
filter: new RegExp("(.+)\\.(" + sails.config.moduleloader.sourceExt.join('|') + ")$"),
useGlobalIdForKeyName: true
}, bindToSails(cb));
},
Expand Down

0 comments on commit 0486dd8

Please sign in to comment.