Skip to content

Commit

Permalink
Redirects: fix prefix redirects (#10828)
Browse files Browse the repository at this point in the history
We were using the path (filename) to match
prefix redirects, but we should be using the full_path.
  • Loading branch information
stsewd authored Oct 23, 2023
1 parent f01c60e commit 0691f5d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions readthedocs/proxito/tests/test_old_redirects.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,13 @@ def test_redirect_root(self):
"http://project.dev.readthedocs.io/en/latest/faq.html",
)

# Prefix redirects should match the whole path.
with self.assertRaises(Http404):
self.client.get(
"/en/latest/woot/faq.html",
headers={"host": "project.dev.readthedocs.io"},
)

def test_redirect_page(self):
Redirect.objects.create(
project=self.project,
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/redirects/querysets.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def get_redirect_path_with_status(
)
prefix = Q(
redirect_type="prefix",
path__startswith=F("from_url"),
full_path__startswith=F("from_url"),
)
page = Q(
redirect_type="page",
Expand Down

0 comments on commit 0691f5d

Please sign in to comment.