From f09a79b37ac60d363965b5182e72bab6e3b84124 Mon Sep 17 00:00:00 2001 From: Henry Bevan Date: Wed, 19 Jul 2017 13:20:11 +0100 Subject: [PATCH] Remove colons from the file extension when caching an image. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit iOS doesn’t like having colons in filenames, and Twitter uses colons to identify the size of an image after the filename, e.g. ‘https://pbs.twimg.com/media/foo.jpg:large’, and this library was using the colon in the extension which resulted in images not displaying. The solution was to replace the colons in the extension. (Issue came to light due to using OpenGraph lookups to get appropriate images for embedded tweets) --- src/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.tsx b/src/index.tsx index 35086ce..b9a7c9e 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -26,7 +26,7 @@ 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(".")); + const ext = path.indexOf(".") === -1 ? ".jpg" : path.substring(path.indexOf(".")).replace(':', '_'); if (immutable === true) { return BASE_DIR + "/" + SHA1(uri) + ext; } else {