From 8fe68f73f8745553eac805a072e35f81b9d0716d Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Thu, 2 Jul 2020 00:21:02 -0700 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Jordan Harband --- lib/internal/modules/cjs/loader.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index e61c4f1352e1a2..93a5d6823ca93e 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -40,8 +40,9 @@ const { RegExpPrototypeTest, SafeMap, SafeWeakMap, - Set, + SafeSet, String, + StringPrototypeIncludes, StringPrototypeIndexOf, StringPrototypeLastIndexOf, StringPrototypeMatch, @@ -574,7 +575,7 @@ function resolveExportsTarget(baseUrl, target, subpath, mappingKey) { return fileURLToPath(resolved); } catch (err) { if (err.code === 'ERR_INVALID_FILE_URL_PATH' && - err.message.includes('must not include encoded "/" characters')) { + StringPrototypeIncludes(err.message, 'must not include encoded "/" characters')) { throw new ERR_INVALID_MODULE_SPECIFIER( resolved.pathname, 'must not include encoded "/" characters', fileURLToPath(baseUrl)); @@ -990,7 +991,7 @@ Module._load = function(request, parent, isMain) { }; // TODO: Use this set when resolving pkg#exports conditions. -const cjsConditions = new Set(['require', 'node']); +const cjsConditions = new SafeSet(['require', 'node']); Module._resolveFilename = function(request, parent, isMain, options) { if (NativeModule.canBeRequiredByUsers(request)) { return request;