MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / validateUrl

Function validateUrl

apps/api/src/controllers/misc.controller.ts:30–41  ·  view source on GitHub ↗
(raw?: string)

Source from the content-addressed store, hash-verified

28}
29
30function validateUrl(raw?: string): URL | null {
31 try {
32 if (!raw) throw new Error('Missing ?url');
33 const url = new URL(raw);
34 if (url.protocol !== 'http:' && url.protocol !== 'https:') {
35 throw new Error('Only http/https URLs are allowed');
36 }
37 return url;
38 } catch (error) {
39 return null;
40 }
41}
42
43// Binary cache functions (more efficient than base64)
44async function getFromCacheBinary(

Callers 2

getFaviconFunction · 0.85
getOgImageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected