diff options
author | cjihrig <cjihrig@gmail.com> | 2019-05-09 20:25:28 -0400 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2019-05-13 13:07:52 -0400 |
commit | ef51cc8ac937ac44bfe8b8ec000b7f04f170abd5 (patch) | |
tree | d73f6c33e44496cb9d83cb22c743a8fe0d0c9764 /lib/internal/modules/cjs | |
parent | 6be5c3bdae06d20b3daaa759d93e4062c25319fc (diff) | |
download | node-new-ef51cc8ac937ac44bfe8b8ec000b7f04f170abd5.tar.gz |
module: fix createRequireFromPath() slash logic
The trailing slash detection logic in createRequireFromPath()
seemed slightly incorrect. This commit reworks the logic.
PR-URL: https://github.com/nodejs/node/pull/27634
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'lib/internal/modules/cjs')
-rw-r--r-- | lib/internal/modules/cjs/loader.js | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index b101f23dbe..428f5452c6 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -838,7 +838,7 @@ Module.runMain = function() { function createRequireFromPath(filename) { // Allow a directory to be passed as the filename const trailingSlash = - filename.endsWith(path.sep) || path.sep !== '/' && filename.endsWith('\\'); + filename.endsWith('/') || (isWindows && filename.endsWith('\\')); const proxyPath = trailingSlash ? path.join(filename, 'noop.js') : |