Skip to content

Commit 140b44f

Browse files
cjihrigtargos
authored andcommitted
module: fix createRequireFromPath() slash logic
The trailing slash detection logic in createRequireFromPath() seemed slightly incorrect. This commit reworks the logic. PR-URL: #27634 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yongsheng Zhang <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 7923b4a commit 140b44f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/internal/modules/cjs/loader.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ Module.runMain = function() {
838838
function createRequireFromPath(filename) {
839839
// Allow a directory to be passed as the filename
840840
const trailingSlash =
841-
filename.endsWith(path.sep) || path.sep !== '/' && filename.endsWith('\\');
841+
filename.endsWith('/') || (isWindows && filename.endsWith('\\'));
842842

843843
const proxyPath = trailingSlash ?
844844
path.join(filename, 'noop.js') :

0 commit comments

Comments
 (0)