mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
module: simplify createRequire() validation
PR-URL: https://github.com/nodejs/node/pull/27629 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
88b4d00fc6
commit
c33e83497e
1 file changed
+3
-4
@@ -858,10 +858,9 @@ const createRequireError = 'must be a file URL object, file URL string, or' +
|
||||
|
||||
function createRequire(filename) {
|
||||
let filepath;
|
||||
if (typeof filename === 'object' && !(filename instanceof URL)) {
|
||||
throw new ERR_INVALID_ARG_VALUE('filename', filename, createRequireError);
|
||||
} else if (typeof filename === 'object' ||
|
||||
typeof filename === 'string' && !path.isAbsolute(filename)) {
|
||||
|
||||
if (filename instanceof URL ||
|
||||
(typeof filename === 'string' && !path.isAbsolute(filename))) {
|
||||
try {
|
||||
filepath = fileURLToPath(filename);
|
||||
} catch {
|
||||
|
||||
Reference in new issue
Block a user