(url: string, packageName: string, repoInfo?: RepositoryInfo)
| 413 | // Proxy URLs are HMAC-signed to prevent open proxy abuse. |
| 414 | // See: https://github.com/npmx-dev/npmx.dev/issues/1138 |
| 415 | function resolveImageUrl(url: string, packageName: string, repoInfo?: RepositoryInfo): string { |
| 416 | // Skip already-proxied URLs (from a previous resolveImageUrl call in the |
| 417 | // marked renderer — sanitizeHtml transformTags may call this again) |
| 418 | if (url.startsWith('/api/registry/image-proxy')) { |
| 419 | return url |
| 420 | } |
| 421 | const resolved = resolveUrl(url, packageName, repoInfo) |
| 422 | const rawUrl = repoInfo?.provider |
| 423 | ? convertBlobOrFileToRawUrl(resolved, repoInfo.provider) |
| 424 | : resolved |
| 425 | const { imageProxySecret } = useRuntimeConfig() |
| 426 | return toProxiedImageUrl(rawUrl, imageProxySecret) |
| 427 | } |
| 428 | |
| 429 | // Helper to prefix id attributes with 'user-content-' |
| 430 |
no test coverage detected