(rawUrl: string)
| 370 | } |
| 371 | |
| 372 | private normalizeHttpUrl(rawUrl: string): { success: boolean; url?: string } { |
| 373 | const candidate = this.ensureUrlProtocol(rawUrl.trim()) |
| 374 | try { |
| 375 | const parsed = new URL(candidate) |
| 376 | if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') { |
| 377 | return { success: false } |
| 378 | } |
| 379 | return { success: true, url: parsed.toString() } |
| 380 | } catch { |
| 381 | return { success: false } |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | private ensureUrlProtocol(url: string): string { |
| 386 | if (/^https?:\/\//i.test(url)) { |
no test coverage detected