import type { ImageURISource } from 'react-native'; const isHttpUrl = (uri: string): boolean => /^https?:\/\//i.test(uri.trim()); /** * Remote images: use the platform HTTP cache (respects Cache-Control from the server). * Local / data URIs: unchanged. */ export function cachedImageSource(uri: string): ImageURISource { const u = uri.trim(); if (isHttpUrl(u)) { return { uri: u, cache: 'default' }; } return { uri: u }; } /** * Remote video: enable react-native-video disk cache for repeat views and buffering. * Local / content URIs: no network flags. */ export function cachedVideoSource(uri: string): { uri: string; isNetwork?: boolean; shouldCache?: boolean; } { const u = uri.trim(); if (isHttpUrl(u)) { return { uri: u, isNetwork: true, shouldCache: true }; } return { uri: u }; }