MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / parseOpenNoteDeepLink

Function parseOpenNoteDeepLink

apps/desktop/src/main/deep-links.ts:35–54  ·  view source on GitHub ↗
(rawUrl: string)

Source from the content-addressed store, hash-verified

33}
34
35export function parseOpenNoteDeepLink(rawUrl: string): OpenNoteDeepLinkRequest | null {
36 const trimmed = rawUrl.trim()
37 if (!trimmed) return null
38
39 let parsed: URL
40 try {
41 parsed = new URL(trimmed)
42 } catch {
43 return null
44 }
45
46 if (parsed.protocol !== `${ZENNOTES_DEEP_LINK_SCHEME}:`) return null
47
48 const action = deepLinkAction(parsed)
49 const target = OPEN_NOTE_ACTION_TARGETS[action]
50 if (!target) return null
51
52 const notePath = normalizeDeepLinkNotePath(parsed.searchParams.get('path'))
53 return notePath ? { target, path: notePath } : null
54}
55
56export function normalizeDeepLinkNotePath(rawPath: string | null | undefined): string | null {
57 const trimmed = rawPath?.trim()

Callers 2

handleExternalOpenUrlFunction · 0.90
deep-links.test.tsFile · 0.90

Calls 2

deepLinkActionFunction · 0.85

Tested by

no test coverage detected