From 50816d4c1f1f4cd4006d3a64e000820c6ec3edaa Mon Sep 17 00:00:00 2001 From: Ihor Aleksandrychiev Date: Wed, 8 Apr 2026 10:36:01 +0300 Subject: [PATCH] Fixed URL switching logic for versions 3.27+ and maseter/lts Ticket: ENT-13842 Signed-off-by: Ihor Aleksandrychiev --- 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)