Skip to content

Commit

Permalink
Fix content index title when domains are enabled
Browse files Browse the repository at this point in the history
fixes: #4253
  • Loading branch information
gerrod3 committed Jun 24, 2024
1 parent a0e4341 commit 530a9fb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES/4253.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed path title at content directory index to include domain's name when enabled.
5 changes: 4 additions & 1 deletion pulpcore/content/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,9 @@ def render_html(directory_list, path="", dates=None, sizes=None):
"""
dates = dates or {}
sizes = sizes or {}
root = path == settings.CONTENT_PATH_PREFIX
if root and settings.DOMAIN_ENABLED:
path += f"{get_domain().name}/"
template = Template(
"""
<html>
Expand Down Expand Up @@ -439,7 +442,7 @@ def render_html(directory_list, path="", dates=None, sizes=None):
dir_list=sorted(directory_list),
dates=dates,
path=path,
root=path == settings.CONTENT_PATH_PREFIX,
root=root,
sizes=sizes,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,14 @@ def test_zero_byte_file_listing(
z_line = [i for i in response.decode("utf-8").split("\n") if i.startswith('<a href="zero">')]
assert len(z_line) == 1
assert z_line[0].endswith("0 Bytes")


@pytest.mark.parallel
def test_content_index_title(pulp_content_url, pulp_settings, http_get):
title = pulp_settings.CONTENT_PATH_PREFIX
if pulp_settings.DOMAIN_ENABLED:
title += "default/"

response = http_get(pulp_content_url).decode("utf-8")
assert f"<head><title>Index of {title}</title></head>" in response
assert f"<h1>Index of {title}</h1>" in response

0 comments on commit 530a9fb

Please sign in to comment.