Remove colons from the file extension when caching an image.#60
Remove colons from the file extension when caching an image.#60henrytndrly wants to merge 2 commits intowcandillon:masterfrom
Conversation
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)
|
Thank for doing this! What do you mean by iOS doesn't like colons in filenames? Is there a specification of the supported filenames? It would be good then to support all of them in this PR. |
|
TL;DR: It's only colons that need to be processed... -- The initial guidance I saw was this SO post: https://stackoverflow.com/questions/4924898/how-to-preserve-colon-character-in-filename-when-using-nsdata-method-writetofil so I just tried to replace the colon character, and the image started showing. A bit more googling suggests that it is 'just' colons that are not liked (beyond slashes, but they're already treated as a directory separator...) Also found this google result which I think is the 'most' authoritative... https://books.google.co.uk/books?id=62xkJo6JXwAC&pg=PA616&lpg=PA616&dq=darwin+allowed+characters+in+file+names&source=bl&ots=PBQiurDAwK&sig=NE_nieRW_2iaZ3UyrfWsaSZ49wc&hl=en&sa=X&ved=0ahUKEwir2dLvyJXVAhXJB8AKHZmdBRgQ6AEITjAF#v=onepage&q=darwin%20allowed%20characters%20in%20file%20names&f=false I've not yet found any Apple sourced specification on allowed characters. |
|
(Also: my app is just focussing on iOS at the moment, however I think the code should also work on Android, as that probably doesn't care in the first place, and we're just operating on an 'internal' identifier) |
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)