MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / schemeHint

Function schemeHint

runtime/src/prefetch.js:14–26  ·  view source on GitHub ↗
(spec)

Source from the content-addressed store, hash-verified

12
13/* Hint when a module spec likely can't load: insecure scheme or schemeless URL. Null when it looks fine. */
14function schemeHint(spec) {
15 if (spec.startsWith('http://')) {
16 return `'${spec}' uses http://; browsers block http subresources from an https page `
17 + `(mixed content), so the fetch never leaves. Use https:// (an SSL connection).`;
18 }
19 // No scheme but a dotted first segment looks like a domain, yet the host treats it as a relative path.
20 const relative = spec.startsWith('.') || spec.startsWith('/') || spec.includes('://');
21 if (!relative && spec.split('/')[0].includes('.')) {
22 return `'${spec}' has no scheme, so it resolved as a path on your own origin. `
23 + `If it's a URL, prefix it with https://.`;
24 }
25 return null;
26}
27
28/* Imports of `src`, classified, via the compiler (single source of truth). Returns [{ bare, spec }]. */
29function scanImports(src, exports) {

Callers 1

bfsPrefetchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected