MCPcopy Create free account
hub / github.com/dwgx/WindsurfAPI / validateImageUrl

Function validateImageUrl

src/image.js:28–36  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

26}
27
28function 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
38export function parseDataUrl(url) {
39 const clean = url.replace(/\s/g, '');

Callers 1

fetchImageUrlFunction · 0.85

Calls 1

isPrivateIpFunction · 0.90

Tested by

no test coverage detected