(url)
| 26 | } |
| 27 | |
| 28 | function validateImageUrl(url) { |
| 29 | let parsed; |
| 30 | try { parsed = new URL(url); } catch { throw new Error('Invalid image URL'); } |
| 31 | if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') |
| 32 | throw new Error('Image URL must be http or https'); |
| 33 | if (String(parsed.hostname).toLowerCase() === 'localhost' || isPrivateIp(parsed.hostname)) |
| 34 | throw new Error('Image URL targets a private/internal address'); |
| 35 | return parsed; |
| 36 | } |
| 37 | |
| 38 | export function parseDataUrl(url) { |
| 39 | const clean = url.replace(/\s/g, ''); |
no test coverage detected