mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
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>
This commit is contained in:
@@ -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') :
|
||||
|
||||
Reference in New Issue
Block a user