-
Notifications
You must be signed in to change notification settings - Fork 438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AnyImageImporter: recognize uppercase .JPEG, .JPG #312
Conversation
Huh, interesting, why I didn't do this already... What about applying Utility::String::lowercase() on the filename first and then do all these comparisons on lowercase? Since there could be also Bonus point: if you'd do this also for all other |
Ah okay, that would also work. Does some unnecessary work since we are just interested in the suffix, but that sounds ok to me.
Sure, will do so :-) |
Yep, you're right. Ideally having some "split extension" function and then lowercase just the suffix. Such API addition is buried somewhere on my TODO list, once it gets implemented I'll update this :) So far I think using
Thanks! 👍 |
I haven't actually tested it yet, will do so tomorrow. |
Thanks a lot! For the testing -- I think it could be enough to just copy one small file in each test, rename it with uppercase extension (of course also a different basename, to avoid issues on case-insensitive filesystems) and duplicate the test case with different filename. As far as I understand Git internals, such a copy won't result in any repository bloat since files with the same contents are stored just once. |
Codecov Report
@@ Coverage Diff @@
## master #312 +/- ##
==========================================
+ Coverage 53.36% 53.37% +0.01%
==========================================
Files 325 325
Lines 16742 16746 +4
==========================================
+ Hits 8934 8938 +4
Misses 7808 7808
Continue to review full report at Codecov.
|
Added unit tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonderful, I'm 99.9% happy :) Let's see what the CIs say, but apart from the one thing below (which I think would cause the Android builds to fail) I think this is good to merge :)
Great work! 👍
@@ -25,8 +25,10 @@ | |||
|
|||
if(CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_ANDROID) | |||
set(WAV_FILE stereo8.wav) | |||
set(UPPERCASE_WAV_FILE uppercase.wav) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uppercase.WAV
? :)
Thanks for the catch - found another of these typos. The |
Yeah, you're right :) Except the cases suffixed Thinking more about this, I should rewrite tests for the others in a similar way, to have better coverage. And now I'm also realizing the extension matching should fall back to detection by contents if no extension gets matched. So it's possible to also open random internet files like |
Okay, should we leave the test file there, then? I don't really care either way ;-)
👍 |
I will remove the |
Merged as a480c70. I did the test rewrite and applied this after, which made the diff significantly smaller (and without any extra files needed). Thanks a lot for the contribution! 👍 |
I'm loading textures in my application from a source I have no control over - and these strange people use
.JPEG
as file suffix, which is not recognized byAnyImageImporter
.I briefly looked into implementing a case-insensitive version of
Corrade::Utility::String::endsWith
, but I'm not sure if you would want that. It also runs into problems with UTF8, but I guess in this case that would be fine (nobody uses UTF8 inside suffixes).