diff options
author | Chris Yip <i@chrisyip.im> | 2015-04-21 15:13:27 +0800 |
---|---|---|
committer | Roman Reiss <me@silverwind.io> | 2015-04-23 16:57:50 +0200 |
commit | 7384ca83f97a28b0cecaabe879e9af0fe8631b62 (patch) | |
tree | b7340c33eef3ae6e616b87e62f03c91c36f8e6a3 /lib | |
parent | a7d74633f20e285395f5e2860bdac56381603476 (diff) | |
download | android-node-v8-7384ca83f97a28b0cecaabe879e9af0fe8631b62.tar.gz android-node-v8-7384ca83f97a28b0cecaabe879e9af0fe8631b62.tar.bz2 android-node-v8-7384ca83f97a28b0cecaabe879e9af0fe8631b62.zip |
module: remove '' from Module.globalPaths
If `$NODE_PATH` contains trailing separators, `Module.globalPaths` will
contains empty strings. When `Module` try to resolve a module's path,
`path.resolve('', 'index.js')` will boil down to `$PWD/index.js`, which
makes sub modules can access global modules and get unexpected result.
PR-URL: https://github.com/iojs/io.js/pull/1488
Reviewed-By: Roman Reiss <me@silverwind.io>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/module.js | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/module.js b/lib/module.js index 02f0ec700f..eba3de8171 100644 --- a/lib/module.js +++ b/lib/module.js @@ -489,7 +489,9 @@ Module._initPaths = function() { var nodePath = process.env['NODE_PATH']; if (nodePath) { - paths = nodePath.split(path.delimiter).concat(paths); + paths = nodePath.split(path.delimiter).filter(function(path) { + return !!path; + }).concat(paths); } modulePaths = paths; |