Skip to content

fix(reports): serve app icons without language redirect - #702

Open
Manny7717 wants to merge 1 commit into
Exodus-Privacy:v1from
Manny7717:fix/icon-no-redirect
Open

fix(reports): serve app icons without language redirect#702
Manny7717 wants to merge 1 commit into
Exodus-Privacy:v1from
Manny7717:fix/icon-no-redirect

Conversation

@Manny7717

Copy link
Copy Markdown

What

App icon URLs (/reports/<id>/icon and /reports/<handle>/latest/icon) were only registered inside i18n_patterns. A request without a language prefix therefore fell through to a 404 and Django's LocaleMiddleware responded 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

  • Register the two icon endpoints as non-localized routes in the root urls.py (reports/<int:app_id>/icon/ and reports/<handle>/latest/icon/), outside i18n_patterns. Icons are binary content, not localized pages — they don't need a language prefix.
  • The language-prefixed routes remain for backward compatibility.
  • report_details.html now 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

  • New regression test 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).
  • Full suite: manage.py test69/69 OK (existing icon tests unchanged).
  • flake8 clean on changed files.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Force django to serve this icon without language redirection

1 participant