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

Function normalizeDeepLinkNotePath

apps/desktop/src/main/deep-links.ts:56–69  ·  view source on GitHub ↗
(rawPath: string | null | undefined)

Source from the content-addressed store, hash-verified

54}
55
56export function normalizeDeepLinkNotePath(rawPath: string | null | undefined): string | null {
57 const trimmed = rawPath?.trim()
58 if (!trimmed || trimmed.includes('\0')) return null
59
60 const slashPath = trimmed.replace(/\\/g, '/')
61 if (slashPath.startsWith('/') || /^[a-zA-Z]:\//.test(slashPath)) return null
62 if (slashPath.split('/').some((part) => part === '..')) return null
63
64 const normalized = path.posix.normalize(slashPath)
65 if (normalized === '.' || normalized === '..' || normalized.startsWith('../')) return null
66 if (path.posix.isAbsolute(normalized)) return null
67
68 return normalized
69}

Callers 1

parseOpenNoteDeepLinkFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected