MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / validateUrl

Function validateUrl

pkg/npm/install.js:69–80  ·  view source on GitHub ↗
(rawUrl)

Source from the content-addressed store, hash-verified

67// Security: only follow HTTPS URLs (defense-in-depth). Parse the URL instead
68// of relying on a string prefix so every redirect is checked unambiguously.
69function validateUrl(rawUrl) {
70 let parsed;
71 try {
72 parsed = new URL(rawUrl);
73 } catch (err) {
74 throw new Error(`Invalid download URL ${rawUrl}: ${err.message}`);
75 }
76 if (parsed.protocol !== 'https:' || !parsed.hostname || parsed.username || parsed.password) {
77 throw new Error(`Refusing non-HTTPS or credentialed URL: ${rawUrl}`);
78 }
79 return parsed.href;
80}
81
82// Plain HTTP is accepted only for an exact loopback authority, as in
83// install.sh; such a fetch uses no proxy and follows no redirect.

Callers 2

downloadHopFunction · 0.85
downloadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected