MCPcopy Index your code
hub / github.com/freeCodeCamp/freeCodeCamp / normalizeTwitter

Function normalizeTwitter

api/src/utils/normalize.ts:29–41  ·  view source on GitHub ↗
(
  handleOrUrl: string | null
)

Source from the content-addressed store, hash-verified

27 * @returns Twitter URL.
28 */
29export const normalizeTwitter = (
30 handleOrUrl: string | null
31): string | undefined => {
32 if (!handleOrUrl) return undefined;
33
34 let url;
35 try {
36 new URL(handleOrUrl);
37 } catch {
38 url = `https://x.com/${handleOrUrl.replace(/^@/, '')}`;
39 }
40 return url ?? handleOrUrl;
41};
42
43/**
44 * Converts a Bluesky handle or URL to a URL.

Callers 3

normalize.test.tsFile · 0.85
userPublicGetRoutesFunction · 0.85
getSessionUserHandlerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected