(source: string)
| 16 | const SHA_RE = /^[0-9a-f]{7,40}$/; |
| 17 | |
| 18 | export function resolveInstallSource(source: string): ResolvedSource { |
| 19 | const trimmed = source.trim(); |
| 20 | |
| 21 | const github = parseGithubUrl(trimmed); |
| 22 | if (github !== undefined) return github; |
| 23 | |
| 24 | if (trimmed.startsWith('http://') || trimmed.startsWith('https://')) { |
| 25 | return { kind: 'zip-url', path: trimmed }; |
| 26 | } |
| 27 | if (!path.isAbsolute(trimmed)) { |
| 28 | throw new Error(`Plugin root must be an absolute path (got "${source}")`); |
| 29 | } |
| 30 | return { kind: 'local-path', path: trimmed }; |
| 31 | } |
| 32 | |
| 33 | function parseGithubUrl(raw: string): ResolvedSource | undefined { |
| 34 | let url: URL; |
no test coverage detected