fix(reports): serve app icons without language redirect - #702
Open
Manny7717 wants to merge 1 commit into
Open
Conversation
Icon URLs such as /reports/<id>/icon were only defined inside i18n_patterns, so Django's LocaleMiddleware redirected every language-less request (302 to /<lang>/reports/<id>/icon/). This adds non-localized routes for the icon endpoints, so icons are served directly; the report page no longer needs the hardcoded language-code workaround. Closes Exodus-Privacy#557
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
App icon URLs (
/reports/<id>/iconand/reports/<handle>/latest/icon) were only registered insidei18n_patterns. A request without a language prefix therefore fell through to a 404 and Django'sLocaleMiddlewareresponded with a 302 redirect to/<lang>/reports/<id>/icon/. Every icon<img>on the site paid that extra round-trip, and external references (scrapers, embeds) got redirected too. Fixes #557.Change
urls.py(reports/<int:app_id>/icon/andreports/<handle>/latest/icon/), outsidei18n_patterns. Icons are binary content, not localized pages — they don't need a language prefix.report_details.htmlnow uses{% url 'app_icon' ... %}instead of the hardcoded/{LANGUAGE_CODE}/reports/...workaround from Fix icon redirection by adding language code and leading slash to URI #554.Tests
test_icon_served_without_language_redirect: GET/reports/<id>/icon/(no language prefix,follow=False) now returns 200 directly; it previously returned 302 (verified by running the test with the routes removed —AssertionError: 302 != 200).manage.py test→ 69/69 OK (existing icon tests unchanged).flake8clean on changed files.