mirror of
https://github.com/zulip/zulip.git
synced 2025-10-22 20:42:14 +00:00
docs: Remove trailing slash from canonical URL for non-root docs.
The root pages for API, integrations and policies documentation have a trailing slash for the canoncial URL, but the individual articles on those pages do not have a trailing slash for the page we want to mark as canonical.
This commit is contained in:
committed by
Alex Vandiver
parent
e9cdf6f41c
commit
9de4618202
@@ -251,6 +251,14 @@ class DocPageTest(ZulipTestCase):
|
||||
)
|
||||
self.assertEqual(result.status_code, 404)
|
||||
|
||||
result = self.client_get(
|
||||
# Non-root API docs pages do not have a trailing slash.
|
||||
"/api/changelog/",
|
||||
follow=True,
|
||||
HTTP_X_REQUESTED_WITH="XMLHttpRequest",
|
||||
)
|
||||
self.assertEqual(result.status_code, 404)
|
||||
|
||||
def test_dev_environment_endpoints(self) -> None:
|
||||
self._test("/devlogin/", ["Normal users"])
|
||||
self._test("/devtools/", ["Useful development URLs"])
|
||||
|
@@ -77,7 +77,12 @@ def add_api_url_context(
|
||||
|
||||
|
||||
def add_canonical_link_context(context: dict[str, Any], request: HttpRequest) -> None:
|
||||
context["REL_CANONICAL_LINK"] = f"https://zulip.com{request.path}"
|
||||
if request.path in ["/api/", "/policies/", "/integrations/"]:
|
||||
# Root doc pages have a trailing slash in the canonical URL.
|
||||
canonical_path = request.path
|
||||
else:
|
||||
canonical_path = request.path.removesuffix("/")
|
||||
context["REL_CANONICAL_LINK"] = f"https://zulip.com{canonical_path}"
|
||||
|
||||
|
||||
class ApiURLView(TemplateView):
|
||||
|
Reference in New Issue
Block a user