From 4186209ba3282e5bff80fb9e1dbcd02bfefae180 Mon Sep 17 00:00:00 2001 From: Ihor Aleksandrychiev Date: Wed, 8 Apr 2026 10:36:01 +0300 Subject: [PATCH 1/2] Fixed URL switching logic for versions 3.27+ and maseter/lts Ticket: ENT-13842 Signed-off-by: Ihor Aleksandrychiev (cherry picked from commit 50816d4c1f1f4cd4006d3a64e000820c6ec3edaa) --- generator/_scripts/cfdoc_patch_header_nav.py | 31 ++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/generator/_scripts/cfdoc_patch_header_nav.py b/generator/_scripts/cfdoc_patch_header_nav.py index 3920786cc..9f616a823 100644 --- a/generator/_scripts/cfdoc_patch_header_nav.py +++ b/generator/_scripts/cfdoc_patch_header_nav.py @@ -25,6 +25,25 @@ import sys +def should_replace_version(version): + # always trigger for master or lts + special_versions = ["master", "lts"] + + if version in special_versions: + return True + + # handle numeric versions: if the version is 3.27 or higher, replace the version in the URL + # starting with 3.27 we changed the URL structure, so for older versions like 3.24 + # replacing the version would lead to the 404 page. In that case, redirect to the main page. + try: + if float(version) >= 3.27: + return True + except ValueError: + return False + + return False + + def patch(current_branch, lts_version): url = "https://docs.cfengine.com/docs/branches.json" response = urllib.request.urlopen(url) @@ -48,12 +67,20 @@ def patch(current_branch, lts_version): continue selected = "" link = branch["Link"] + replaceVersionInLcocation = should_replace_version(branch["Version"]) if branch["Version"] == current_branch: selected = ' selected="selected"' link = "javascript:void(0);" + replaceVersionInLcocation = False print( - '%s' - % (link, selected, branch["Title"].replace("Version ", "")), + "%s" + % ( + link, + current_branch, + str(replaceVersionInLcocation).lower(), + selected, + branch["Title"].replace("Version ", ""), + ), file=f, ) print('view all versions', file=f) From cb0fc38dd52383a619c4faa964e054cf2b4c99a1 Mon Sep 17 00:00:00 2001 From: Ihor Aleksandrychiev Date: Thu, 23 Apr 2026 10:55:23 +0300 Subject: [PATCH 2/2] Lowered version threshold for URL rewriting to 3.24 Signed-off-by: Ihor Aleksandrychiev (cherry picked from commit 685c1330d700f61bbae4135e8d1dd748c5ded8df) --- generator/_scripts/cfdoc_patch_header_nav.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/generator/_scripts/cfdoc_patch_header_nav.py b/generator/_scripts/cfdoc_patch_header_nav.py index 9f616a823..697225e46 100644 --- a/generator/_scripts/cfdoc_patch_header_nav.py +++ b/generator/_scripts/cfdoc_patch_header_nav.py @@ -32,11 +32,11 @@ def should_replace_version(version): if version in special_versions: return True - # handle numeric versions: if the version is 3.27 or higher, replace the version in the URL - # starting with 3.27 we changed the URL structure, so for older versions like 3.24 + # handle numeric versions: if the version is 3.24 or higher, replace the version in the URL + # starting with 3.24 we changed the URL structure, so for older versions like 3.21 # replacing the version would lead to the 404 page. In that case, redirect to the main page. try: - if float(version) >= 3.27: + if float(version) >= 3.24: return True except ValueError: return False