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

Function getGitHubHandle

website/src/scripts/utils.ts:397–415  ·  view source on GitHub ↗
(
  url: string | null | undefined,
  fallback = ""
)

Source from the content-addressed store, hash-verified

395 * Falls back to the provided value when the URL is not a github.com profile.
396 */
397export function getGitHubHandle(
398 url: string | null | undefined,
399 fallback = ""
400): string {
401 if (!url) return fallback;
402 try {
403 const parsed = new URL(url);
404 const host = parsed.hostname.replace(/^www\./, "");
405 if (host === "github.com") {
406 const segments = parsed.pathname.split("/").filter(Boolean);
407 if (segments.length === 1) {
408 return `@${segments[0]}`;
409 }
410 }
411 } catch {
412 // Invalid URL
413 }
414 return fallback;
415}
416
417/**
418 * Truncate text with ellipsis

Callers 2

openDetailsModalFunction · 0.90
renderExtensionsHtmlFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected