From 2492028a37cfb200ce7dcfec72a36a7426386efd 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 | 33 +++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/generator/_scripts/cfdoc_patch_header_nav.py b/generator/_scripts/cfdoc_patch_header_nav.py index 3920786cc..61a533561 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) @@ -47,13 +66,19 @@ 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" + % ( + branch["Version"], + current_branch, + str(replaceVersionInLcocation).lower(), + selected, + branch["Title"].replace("Version ", ""), + ), file=f, ) print('view all versions', file=f)