This commit is contained in:
2026-08-27 14:30:26 +08:00
parent c704032d66
commit a5a803046b
11 changed files with 178 additions and 66 deletions
+15
View File
@@ -0,0 +1,15 @@
export function resolveEvidencePreviewUrl(previewUrl, baseUrl) {
const rawUrl = String(previewUrl || '')
const normalizedBase = String(baseUrl || '').replace(/\/$/, '')
if (!rawUrl || /^https?:\/\//i.test(rawUrl)) return rawUrl
if (/^https?:\/\//i.test(normalizedBase)) {
const origin = normalizedBase.match(/^(https?:\/\/[^/]+)/i)?.[1] || ''
return `${origin}${rawUrl.startsWith('/') ? '' : '/'}${rawUrl}`
}
const platformPrefix = '/api/platform/v1'
if (rawUrl === platformPrefix || rawUrl.startsWith(`${platformPrefix}/`)) {
return `${normalizedBase}${rawUrl.slice(platformPrefix.length)}`
}
if (rawUrl.startsWith('/')) return rawUrl
return `${normalizedBase}/${rawUrl}`
}