fix(h5): prevent internal asset host exposure
Some checks failed
CI / verify (push) Has been cancelled

Made-with: Proma
This commit is contained in:
cxk
2026-08-15 19:01:55 +08:00
parent 2edb6bd9f2
commit 00585a7b48
5 changed files with 19 additions and 31 deletions

View File

@@ -12,6 +12,20 @@ describe('normalizeSameOriginPublicUrl', () => {
)).toBe('/app-api/gis/sdk/minio/museum-assets/guide-final/E2/detail.jpg')
})
it('rewrites legacy absolute media and proxy URLs without embedding their host', () => {
expect(normalizeSameOriginPublicUrl(
'http://172.20.14.21:9000/museum-assets/guide-final/E2/detail.jpg'
)).toBe('/app-api/gis/sdk/minio/museum-assets/guide-final/E2/detail.jpg')
expect(normalizeSameOriginPublicUrl(
'http://172.20.14.21:48080/yudao-server/app-api/gis/guide?stopId=1'
)).toBe('/yudao-server/app-api/gis/guide?stopId=1')
expect(normalizeSameOriginPublicUrl(
'http://172.20.14.21:19000/nhm/audio/guide.mp3'
)).toBe('/nhm/audio/guide.mp3')
})
it('keeps ordinary relative paths unchanged', () => {
expect(normalizeSameOriginPublicUrl('/static/placeholder.png'))
.toBe('/static/placeholder.png')