(rawPath: string | null | undefined)
| 54 | } |
| 55 | |
| 56 | export 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 | } |
no outgoing calls
no test coverage detected