Skip to content

Commit 4b87393

Browse files
committed
Fix tests and simplify logic
1 parent 6ad9ceb commit 4b87393

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

readthedocs/proxito/tests/test_urls.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def test_root(self):
1717
self.assertEqual(
1818
match.kwargs, {
1919
'subproject_slug': None,
20+
'subproject_slash': None,
2021
'filename': '',
2122
},
2223
)
@@ -80,6 +81,7 @@ def test_subproject_single_version(self):
8081
self.assertEqual(
8182
match.kwargs, {
8283
'subproject_slug': 'bar',
84+
'subproject_slash': '/',
8385
'filename': 'index.html',
8486
},
8587
)
@@ -91,6 +93,7 @@ def test_subproject_root(self):
9193
self.assertEqual(
9294
match.kwargs, {
9395
'subproject_slug': 'bar',
96+
'subproject_slash': '/',
9497
'filename': '',
9598
},
9699
)
@@ -101,6 +104,7 @@ def test_single_version(self):
101104
self.assertEqual(match.args, ())
102105
self.assertEqual(
103106
match.kwargs, {
107+
'subproject_slash': None,
104108
'subproject_slug': None,
105109
'filename': 'some/path/index.html',
106110
},

readthedocs/proxito/views/serve.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,8 @@ def get(self,
8989
# because it is taken from the host name
9090
version_slug is None or hasattr(request, 'external_domain'),
9191
filename == '',
92-
not final_project.single_version,
93-
]):
94-
return self.system_redirect(request, final_project, lang_slug, version_slug, filename)
95-
96-
# Handle `/projects/subproject` URL redirection
97-
if all([
98-
final_project.single_version,
99-
filename == '',
100-
not subproject_slash,
92+
# Handle `/projects/subproject` and `/projects/subproject/` URL redirects
93+
not final_project.single_version or not subproject_slash,
10194
]):
10295
return self.system_redirect(request, final_project, lang_slug, version_slug, filename)
10396

0 commit comments

Comments
 (0)