Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down