diff options
Diffstat (limited to 'lib/utils/path.js')
-rw-r--r-- | lib/utils/path.js | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/utils/path.js b/lib/utils/path.js index 2d722a5..f195d6c 100644 --- a/lib/utils/path.js +++ b/lib/utils/path.js @@ -1,6 +1,8 @@ var _ = require('lodash'); var path = require('path'); +var error = require('./error'); + // Normalize a filename function normalizePath(filename) { return path.normalize(filename); @@ -15,7 +17,7 @@ function isInRoot(root, filename) { // Resolve paths in a specific folder // Throw error if file is outside this folder function resolveInRoot(root) { - var input, result, err; + var input, result; input = _.chain(arguments) .toArray() @@ -31,9 +33,10 @@ function resolveInRoot(root) { result = path.resolve(root, input); if (!isInRoot(root, result)) { - err = new Error('EACCESS: "' + result + '" not in "' + root + '"'); - err.code = 'EACCESS'; - throw err; + throw new error.FileOutOfScopeError({ + filename: result, + root: root + }); } return result; |