| 12 | |
| 13 | /* Hint when a module spec likely can't load: insecure scheme or schemeless URL. Null when it looks fine. */ |
| 14 | function 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 }]. */ |
| 29 | function scanImports(src, exports) { |