From ef51cc8ac937ac44bfe8b8ec000b7f04f170abd5 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Thu, 9 May 2019 20:25:28 -0400 Subject: [PATCH] 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 Reviewed-By: Yongsheng Zhang Reviewed-By: Ruben Bridgewater Reviewed-By: Rich Trott --- lib/internal/modules/cjs/loader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index b101f23dbe1321..428f5452c6d26d 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') :