(notePath: string, href: string)
| 139 | } |
| 140 | |
| 141 | function resolveVaultRelativeAssetPath(notePath: string, href: string): string | null { |
| 142 | const trimmed = href.trim() |
| 143 | if (!trimmed || trimmed.startsWith('#') || trimmed.startsWith('//')) return null |
| 144 | if (/^[a-zA-Z][a-zA-Z\d+.-]*:/.test(trimmed)) return null |
| 145 | |
| 146 | const normalizedNotePath = notePath.split(path.sep).join('/') |
| 147 | const noteDir = path.posix.dirname(normalizedNotePath) |
| 148 | const decodedHref = decodeHrefPath(trimmed) |
| 149 | const relativeTarget = decodedHref.startsWith('/') |
| 150 | ? decodedHref.replace(/^\/+/, '') |
| 151 | : path.posix.normalize(path.posix.join(noteDir === '.' ? '' : noteDir, decodedHref)) |
| 152 | if (relativeTarget === '..' || relativeTarget.startsWith('../')) return null |
| 153 | return relativeTarget |
| 154 | } |
| 155 | |
| 156 | function remoteAssetUrl(assetPath: string): string | null { |
| 157 | if (remoteWorkspaceInfo?.mode !== 'remote' || !remoteWorkspaceInfo.baseUrl) return null |
no test coverage detected