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}` }