Files
JKVideo/utils/imageUrl.ts

18 lines
590 B
TypeScript
Raw Normal View History

import { Platform } from 'react-native';
/**
* Web B站图片 CDN URL Referer
* Native URLApp axios
*/
export function proxyImageUrl(url: string): string {
2026-03-12 21:21:01 +08:00
if (!url) return url;
if (Platform.OS === 'web') {
return url.replace(
/^https?:\/\/([a-z0-9]+\.hdslb\.com)/,
'http://localhost:3001/bilibili-img/$1',
);
}
// Native: force HTTPS so Release APK doesn't block cleartext HTTP
return url.replace(/^http:\/\//, 'https://');
}