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:
parent
6be5c3bdae
commit
ef51cc8ac9
@ -838,7 +838,7 @@ Module.runMain = function() {
|
|||||||
function createRequireFromPath(filename) {
|
function createRequireFromPath(filename) {
|
||||||
// Allow a directory to be passed as the filename
|
// Allow a directory to be passed as the filename
|
||||||
const trailingSlash =
|
const trailingSlash =
|
||||||
filename.endsWith(path.sep) || path.sep !== '/' && filename.endsWith('\\');
|
filename.endsWith('/') || (isWindows && filename.endsWith('\\'));
|
||||||
|
|
||||||
const proxyPath = trailingSlash ?
|
const proxyPath = trailingSlash ?
|
||||||
path.join(filename, 'noop.js') :
|
path.join(filename, 'noop.js') :
|
||||||
|
Loading…
x
Reference in New Issue
Block a user