diff --git a/src/index.tsx b/src/index.tsx index fe3ff10..3ba3251 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -26,7 +26,11 @@ export class ImageCache { private getPath(uri: string, immutable?: boolean): string { let path = uri.substring(uri.lastIndexOf("/")); path = path.indexOf("?") === -1 ? path : path.substring(path.lastIndexOf("."), path.indexOf("?")); - const ext = path.indexOf(".") === -1 ? ".jpg" : path.substring(path.indexOf(".")); + let ext = path.indexOf(".") === -1 ? ".jpg" : path.substring(path.indexOf(".")); + if(['.jpg','.gif','.jpeg','.png'].indexOf(ext.toLowerCase()) == -1) { // ensure it's a valid extension + ext = '.jpg' + } + if (immutable === true) { return BASE_DIR + "/" + SHA1(uri) + ext; } else { @@ -116,7 +120,7 @@ export class ImageCache { private get(uri: string) { const cache = this.cache[uri]; - if (cache.path) { + if (cache.path && cache.downloading == false) { // We check here if IOS didn't delete the cache content RNFetchBlob.fs.exists(cache.path).then((exists: boolean) => { if (exists) {