Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions core/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,16 @@ def test_docs_libs_gateway_200_non_html(tp, mock_get_file_data):
assert response.content == s3_content


def test_doc_libs_version_redirect(tp):
response = tp.get("redirect-to-library-page", requested_version="1.82.0")
tp.response_302(response)
assert response["Location"] == "/libraries/1.82.0/grid/"

response = tp.get("redirect-to-library-page", requested_version="release")
tp.response_302(response)
assert response["Location"] == "/libraries/"


@pytest.mark.skip(reason="Currently not using iframes for libs docs.")
def test_docs_libs_gateway_200_lib_number_iframe(
tp, mock_get_file_data, mock_get_leaf_data
Expand Down
9 changes: 7 additions & 2 deletions core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@

from config.settings import ENABLE_DB_CACHE
from libraries.constants import LATEST_RELEASE_URL_PATH_STR
from libraries.utils import legacy_path_transform, generate_canonical_library_uri
from libraries.utils import (
legacy_path_transform,
get_prioritized_library_view,
generate_canonical_library_uri,
)
from versions.models import Version

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

# Handle the special case for "release" versions to redirect to the
# most recent Boost release
new_path = f"/libraries/?version=boost-{ requested_version }"
view = get_prioritized_library_view(request)
new_path = f"/libraries/{requested_version}/{view}/"
if requested_version == "release":
new_path = "/libraries/"
return HttpResponseRedirect(new_path)
Expand Down