From 89a58f61d72eb70e582dc79f838530a60be7b971 Mon Sep 17 00:00:00 2001 From: Antoine du HAMEL Date: Thu, 27 Aug 2020 23:36:50 +0200 Subject: [PATCH] module: use isURLInstance instead of instanceof PR-URL: https://github.com/nodejs/node/pull/34951 Backport-PR-URL: https://github.com/nodejs/node/pull/35385 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Derek Lewis --- lib/internal/modules/cjs/loader.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index 280c42b5098d80..4a0bfed2aa0fdb 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -54,7 +54,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'); @@ -1089,7 +1089,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);