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

Function getMsTranscriptApiUrl

api/src/routes/protected/user.ts:51–69  ·  view source on GitHub ↗
(msTranscript: string)

Source from the content-addressed store, hash-verified

49 * @returns Microsoft transcript api url.
50 */
51export function getMsTranscriptApiUrl(msTranscript: string) {
52 try {
53 const url = new URL(msTranscript);
54 const transcriptUrlRegex = /\/transcript\/([^/]+)\/?/;
55 const id = transcriptUrlRegex.exec(url.pathname)?.[1];
56 if (!id) {
57 return { error: `Invalid transcript URL: ${msTranscript}`, data: null };
58 }
59 return {
60 error: null,
61 data: `https://learn.microsoft.com/api/profiles/transcript/share/${id}`
62 };
63 } catch (e) {
64 return {
65 error: `Invalid transcript URL: ${msTranscript}\n${JSON.stringify(e)}`,
66 data: null
67 };
68 }
69}
70
71/**
72 * Wrapper for endpoints related to user account management,

Callers 2

userRoutesFunction · 0.85
user.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected