MCPcopy Index your code
hub / github.com/npmx-dev/npmx.dev / resolveImageUrl

Function resolveImageUrl

server/utils/readme.ts:415–427  ·  view source on GitHub ↗
(url: string, packageName: string, repoInfo?: RepositoryInfo)

Source from the content-addressed store, hash-verified

413// Proxy URLs are HMAC-signed to prevent open proxy abuse.
414// See: https://github.com/npmx-dev/npmx.dev/issues/1138
415function 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

Callers 1

renderReadmeHtmlFunction · 0.85

Calls 3

toProxiedImageUrlFunction · 0.90
resolveUrlFunction · 0.70

Tested by

no test coverage detected