Skip to content

Commit 96524f8

Browse files
committed
Fixed versioned /doc/libs/x.x.x redirects (#1936)
1 parent 8088234 commit 96524f8

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

core/tests/test_views.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,16 @@ def test_docs_libs_gateway_200_non_html(tp, mock_get_file_data):
215215
assert response.content == s3_content
216216

217217

218+
def test_doc_libs_version_redirect(tp):
219+
response = tp.get("redirect-to-library-page", requested_version="1.82.0")
220+
tp.response_302(response)
221+
assert response["Location"] == "/libraries/1.82.0/grid/"
222+
223+
response = tp.get("redirect-to-library-page", requested_version="release")
224+
tp.response_302(response)
225+
assert response["Location"] == "/libraries/"
226+
227+
218228
@pytest.mark.skip(reason="Currently not using iframes for libs docs.")
219229
def test_docs_libs_gateway_200_lib_number_iframe(
220230
tp, mock_get_file_data, mock_get_leaf_data

core/views.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@
2828

2929
from config.settings import ENABLE_DB_CACHE
3030
from libraries.constants import LATEST_RELEASE_URL_PATH_STR
31-
from libraries.utils import legacy_path_transform, generate_canonical_library_uri
31+
from libraries.utils import (
32+
legacy_path_transform,
33+
get_prioritized_library_view,
34+
generate_canonical_library_uri,
35+
)
3236
from versions.models import Version
3337

3438
from .asciidoc import convert_adoc_to_html
@@ -896,7 +900,8 @@ def get(self, request, requested_version):
896900

897901
# Handle the special case for "release" versions to redirect to the
898902
# most recent Boost release
899-
new_path = f"/libraries/?version=boost-{ requested_version }"
903+
view = get_prioritized_library_view(request)
904+
new_path = f"/libraries/{requested_version}/{view}/"
900905
if requested_version == "release":
901906
new_path = "/libraries/"
902907
return HttpResponseRedirect(new_path)

0 commit comments

Comments
 (0)