fix(logo): keep absolute nerkh avatar URLs intact
Stop rewriting legacy upload hosts to SuperAdmin; only prefix relative /uploads/ paths. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,12 +1,3 @@
|
||||
/** هاستهای رجیستری قدیمی که دیگر نباید برای لوگو استفاده شوند */
|
||||
const LEGACY_UPLOAD_HOSTS = new Set([
|
||||
'nerkh.gold',
|
||||
'www.nerkh.gold',
|
||||
'tablo.talasevin.ir',
|
||||
'ah.aygingold.ir',
|
||||
'abshode-service.montgit.ir',
|
||||
])
|
||||
|
||||
function resolveSaBase(): string {
|
||||
try {
|
||||
const last = localStorage.getItem('CONFIG_Success_URL')
|
||||
@@ -21,18 +12,10 @@ function resolveSaBase(): string {
|
||||
return 'https://adm.montzar.ir'
|
||||
}
|
||||
|
||||
/** https://nerkh.gold/uploads/... → https://adm..../uploads/... */
|
||||
/** فقط /uploads/ نسبی؛ URL مطلق (نرخ و …) دست نخورده */
|
||||
export function rewriteLegacyUploadUrl(raw: unknown): string {
|
||||
const value = String(raw || '').trim()
|
||||
if (!value || !/^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 `${resolveSaBase()}${parsed.pathname}`
|
||||
} catch {
|
||||
return value
|
||||
}
|
||||
if (!value) return ''
|
||||
if (value.startsWith('/uploads/')) return `${resolveSaBase()}${value}`
|
||||
return value
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user