MCPcopy Index your code
hub / github.com/nodejs/node / throwIfUnsupportedURLScheme

Function throwIfUnsupportedURLScheme

lib/internal/modules/esm/load.js:179–195  ·  view source on GitHub ↗

* throws an error if the protocol is not one of the protocols * that can be loaded in the default loader * @param {URL} parsed

(parsed)

Source from the content-addressed store, hash-verified

177 * @param {URL} parsed
178 */
179function throwIfUnsupportedURLScheme(parsed) {
180 // Avoid accessing the `protocol` property due to the lazy getters.
181 const protocol = parsed?.protocol;
182 if (
183 protocol &&
184 protocol !== 'file:' &&
185 protocol !== 'data:' &&
186 protocol !== 'node:' &&
187 (
188 protocol !== 'https:' &&
189 protocol !== 'http:'
190 )
191 ) {
192 const schemes = ['file', 'data', 'node'];
193 throw new ERR_UNSUPPORTED_ESM_URL_SCHEME(parsed, schemes);
194 }
195}
196
197/**
198 * For a falsy `format` returned from `load`, throw an error.

Callers 2

defaultLoadFunction · 0.85
defaultLoadSyncFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…