chore: freeze guide and explain update
This commit is contained in:
42
src/utils/publicUrl.ts
Normal file
42
src/utils/publicUrl.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
const SAME_SERVER_HOST = '1.92.206.90'
|
||||
const LEGACY_AUDIO_HOST = '47.120.48.148'
|
||||
|
||||
const isAbsoluteHttpUrl = (url: string) => /^https?:\/\//i.test(url)
|
||||
|
||||
export const normalizeSameOriginPublicUrl = (url: string | null | undefined) => {
|
||||
const value = url?.trim()
|
||||
if (!value || !isAbsoluteHttpUrl(value)) return value || ''
|
||||
|
||||
try {
|
||||
const parsed = new URL(value)
|
||||
const isSameServer = parsed.hostname === SAME_SERVER_HOST
|
||||
|
||||
if (
|
||||
isSameServer
|
||||
&& parsed.port === '9000'
|
||||
&& parsed.pathname.startsWith('/museum-assets/')
|
||||
) {
|
||||
return `${parsed.pathname}${parsed.search}${parsed.hash}`
|
||||
}
|
||||
|
||||
if (
|
||||
isSameServer
|
||||
&& parsed.port === '48080'
|
||||
&& parsed.pathname.startsWith('/yudao-server/')
|
||||
) {
|
||||
return `${parsed.pathname}${parsed.search}${parsed.hash}`
|
||||
}
|
||||
|
||||
if (
|
||||
parsed.hostname === LEGACY_AUDIO_HOST
|
||||
&& parsed.port === '19000'
|
||||
&& parsed.pathname.startsWith('/nhm/audio/')
|
||||
) {
|
||||
return `${parsed.pathname}${parsed.search}${parsed.hash}`
|
||||
}
|
||||
} catch {
|
||||
return value
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
Reference in New Issue
Block a user