module: use isURLInstance instead of instanceof

PR-URL: https://github.com/nodejs/node/pull/34951
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Derek Lewis <DerekNonGeneric@inf.is>
This commit is contained in:
Antoine du HAMEL authored and Node.js GitHub Bot committed 2020-09-15 22:17:47 +00:00
1 parent 8e17383653
commit d24eecd7d7
1 file changed
+2 -2
+2 -2
View File
@@ -60,7 +60,7 @@ const {
maybeCacheSourceMap,
rekeySourceMap
} = require('internal/source_map/source_map_cache');
const { pathToFileURL, fileURLToPath, URL } = require('internal/url');
const { pathToFileURL, fileURLToPath, isURLInstance } = require('internal/url');
const { deprecate } = require('internal/util');
const vm = require('vm');
const assert = require('internal/assert');
@@ -1169,7 +1169,7 @@ const createRequireError = 'must be a file URL object, file URL string, or ' +
function createRequire(filename) {
let filepath;
if (filename instanceof URL ||
if (isURLInstance(filename) ||
(typeof filename === 'string' && !path.isAbsolute(filename))) {
try {
filepath = fileURLToPath(filename);