MCPcopy
hub / github.com/NotionX/react-notion-x / parsePageId

Function parsePageId

packages/notion-utils/src/parse-page-id.ts:14–35  ·  view source on GitHub ↗
(
  id: string | undefined | null = '',
  { uuid = true }: { uuid?: boolean } = {}
)

Source from the content-addressed store, hash-verified

12 * Defaults to returning a UUID (with dashes).
13 */
14export const parsePageId = (
15 id: string | undefined | null = '',
16 { uuid = true }: { uuid?: boolean } = {}
17): string | undefined => {
18 if (!id) return
19
20 id = id.split('?')[0]!
21 if (!id) return
22
23 const match = id.match(pageIdRe)
24
25 if (match) {
26 return uuid ? idToUuid(match[1]) : match[1]
27 }
28
29 const match2 = id.match(pageId2Re)
30 if (match2) {
31 return uuid ? match2[1] : match2[1]!.replaceAll('-', '')
32 }
33
34 return
35}

Callers 8

getPageRawMethod · 0.90
searchMethod · 0.90
notion-api.test.tsFile · 0.90
processPageFunction · 0.90
AssetWrapperFunction · 0.90
TextFunction · 0.90
getPageMethod · 0.90

Calls 1

idToUuidFunction · 0.90

Tested by

no test coverage detected