Skip to content

Commit

Permalink
fixup: assert baseURL is a string for network modules
Browse files Browse the repository at this point in the history
  • Loading branch information
bmeck committed Mar 2, 2022
1 parent c336ad0 commit e0da1a3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/internal/modules/esm/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const {
const { MessageChannel } = require('internal/worker/io');

const {
ERR_INTERNAL_ASSERTION,
ERR_INVALID_ARG_TYPE,
ERR_INVALID_ARG_VALUE,
ERR_INVALID_RETURN_PROPERTY_VALUE,
Expand Down Expand Up @@ -260,6 +261,10 @@ class ESMLoader {
// fetchModule's cache, in which case, fetchModule returns
// immediately and synchronously
url = fetchModule(new URL(url), { parentURL: url }).resolvedHREF;
// This should only occur if the module hasn't been fetched yet
if (typeof url !== 'string') {
throw new ERR_INTERNAL_ASSERTION(`Base url for module ${url} not loaded.`);
}
}
return url;
}
Expand Down

0 comments on commit e0da1a3

Please sign in to comment.