Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Convert thumb extension to lowercase (#2239)
Krystle Salazarc1fd4c0d1bd5
diff --git a/api/api/utils/photon.py b/api/api/utils/photon.pyindex bb5cfb4c4..23c9a7c80 100644--- a/api/api/utils/photon.py+++ b/api/api/utils/photon.py@@ -34,7 +34,7 @@ def _get_file_extension_from_url(image_url: str) -> str:"""Return the image extension if present in the URL."""parsed = urlparse(image_url)_, ext = splitext(parsed.path)- return ext[1:] # remove the leading dot+ return ext[1:].lower() # remove the leading dotdef _get_file_extension_from_content_type(content_type: str) -> str | None:diff --git a/api/test/unit/utils/test_photon.py b/api/test/unit/utils/test_photon.pyindex e0a572a3f..5754669af 100644--- a/api/test/unit/utils/test_photon.py+++ b/api/test/unit/utils/test_photon.py@@ -329,8 +329,9 @@ def test_get_unsuccessful_request_raises_custom_exception():@pytest.mark.parametrize("image_url, expected_ext",[- ("www.example.com/image.jpg", "jpg"),- ("https://example.com/image.jpeg", "jpeg"),+ ("example.com/image.jpg", "jpg"),+ ("www.example.com/image.JPG", "jpg"),+ ("http://example.com/image.jpeg", "jpeg"),("https://subdomain.example.com/image.svg", "svg"),("https://example.com/image.png?foo=1&bar=2#fragment", "png"),("https://example.com/possibleimagewithoutext", ""),