fix(uploads): stop rewriting absolute nerkh logo hosts
Leave absolute avatar URLs alone so SuperAdmin version cards show logos that still live on nerkh. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,11 +1,3 @@
|
||||
const LEGACY_UPLOAD_HOSTS = new Set([
|
||||
'nerkh.gold',
|
||||
'www.nerkh.gold',
|
||||
'tablo.talasevin.ir',
|
||||
'ah.aygingold.ir',
|
||||
'abshode-service.montgit.ir',
|
||||
])
|
||||
|
||||
function saPublicBase(): string {
|
||||
const api = String(import.meta.env.VITE_API_BASE || '')
|
||||
try {
|
||||
@@ -21,20 +13,10 @@ function saPublicBase(): string {
|
||||
return 'https://adm.montzar.ir'
|
||||
}
|
||||
|
||||
/** لوگوهای قدیمی nerkh را از هاست سوپرادمین بخوان */
|
||||
/** فقط /uploads/ نسبی؛ URL مطلق (نرخ و …) دست نخورده */
|
||||
export function rewriteLegacyUploadUrl(raw: unknown): string {
|
||||
const value = String(raw || '').trim()
|
||||
if (!value) return ''
|
||||
if (value.startsWith('/uploads/')) return `${saPublicBase()}${value}`
|
||||
if (!/^https?:\/\//i.test(value)) return value
|
||||
|
||||
try {
|
||||
const parsed = new URL(value)
|
||||
const host = parsed.hostname.toLowerCase()
|
||||
if (!LEGACY_UPLOAD_HOSTS.has(host)) return value
|
||||
if (!/\/uploads\//i.test(parsed.pathname)) return value
|
||||
return `${saPublicBase()}${parsed.pathname}`
|
||||
} catch {
|
||||
return value
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user