MCPcopy
hub / github.com/GitbookIO/gitbook / sanitizeGitBookAppURL

Function sanitizeGitBookAppURL

packages/gitbook/src/lib/app.ts:16–27  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

14 * Sanitize a URL to be a valid GitBook.com app URL.
15 */
16export function sanitizeGitBookAppURL(input: string): string | null {
17 if (!URL.canParse(input)) {
18 return null;
19 }
20
21 const url = new URL(input);
22 if (url.origin !== GITBOOK_APP_URL) {
23 return null;
24 }
25
26 return url.toString();
27}

Callers 1

PDFPageFunction · 0.90

Calls 1

toStringMethod · 0.80

Tested by

no test coverage detected