MCPcopy
hub / github.com/github/awesome-copilot / sanitizeUrl

Function sanitizeUrl

website/src/scripts/utils.ts:378–390  ·  view source on GitHub ↗
(url: string | null | undefined)

Source from the content-addressed store, hash-verified

376 * Only allows http/https protocols, returns '#' for invalid URLs
377 */
378export function sanitizeUrl(url: string | null | undefined): string {
379 if (!url) return "#";
380 try {
381 const parsed = new URL(url);
382 // Only allow http and https protocols
383 if (parsed.protocol === "http:" || parsed.protocol === "https:") {
384 return url;
385 }
386 } catch {
387 // Invalid URL
388 }
389 return "#";
390}
391
392/**
393 * Derive a GitHub @handle from a profile URL

Callers 6

getExternalPluginUrlFunction · 0.90
openDetailsModalFunction · 0.90
renderExtensionsHtmlFunction · 0.90
renderRecipeCardFunction · 0.90
getExternalPluginUrlFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected