From 7af933b016ba56834cd614c7c5479680d631aeee Mon Sep 17 00:00:00 2001 From: KENDAL Date: Tue, 11 Aug 2026 11:19:40 +0300 Subject: [PATCH 1/3] fix(scripts): correctly resolve internal absolute root site URLs to root index.html in check_links.py --- scripts/check_links.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/check_links.py b/scripts/check_links.py index f777edf62..9483ed17e 100644 --- a/scripts/check_links.py +++ b/scripts/check_links.py @@ -160,11 +160,17 @@ def get_file_ids(path): continue parsed = urlparse(link) + is_absolute_internal = False if parsed.scheme and parsed.scheme in ("http", "https"): - if not link.startswith(SITE_URL): + site_url_no_slash = SITE_URL.rstrip("/") + if not link.startswith(SITE_URL) and not link.startswith(site_url_no_slash): continue # External link - # Internal absolute URL (e.g. https://ucp.dev/foo) -> /foo - link = link[len(SITE_URL) - 1 :] # Keep the leading slash + is_absolute_internal = True + if link.startswith(SITE_URL): + link = link[len(SITE_URL) - 1 :] + else: + link = "/" + link[len(site_url_no_slash) :] + parsed = urlparse(link) path_part = parsed.path anchor_part = parsed.fragment @@ -179,7 +185,7 @@ def get_file_ids(path): # Resolve Target File if not path_part: - target_file = file_path + target_file = ROOT_DIR / "index.html" if is_absolute_internal else file_path elif path_part.startswith("/"): # Absolute path from root rel_path = path_part[1:] From 970152470c49e01d5b946a2c9dbf16b5c27aa094 Mon Sep 17 00:00:00 2001 From: KENDAL Date: Tue, 11 Aug 2026 14:45:19 +0300 Subject: [PATCH 2/3] refactor(scripts): refine internal link detection and path normalization per review feedback --- scripts/check_links.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/scripts/check_links.py b/scripts/check_links.py index 9483ed17e..9aa2e2cbd 100644 --- a/scripts/check_links.py +++ b/scripts/check_links.py @@ -160,17 +160,25 @@ def get_file_ids(path): continue parsed = urlparse(link) - is_absolute_internal = False if parsed.scheme and parsed.scheme in ("http", "https"): - site_url_no_slash = SITE_URL.rstrip("/") - if not link.startswith(SITE_URL) and not link.startswith(site_url_no_slash): - continue # External link - is_absolute_internal = True - if link.startswith(SITE_URL): - link = link[len(SITE_URL) - 1 :] + parsed_site = urlparse(SITE_URL) + if parsed.hostname == parsed_site.hostname: + path = parsed.path if parsed.path else "/" + site_path = parsed_site.path + site_path_no_slash = site_path.rstrip("/") + if (path == site_path_no_slash) or path.startswith(site_path): + if path.startswith(site_path): + rel_link_path = "/" + path[len(site_path) :] + else: + rel_link_path = "/" + query_part = f"?{parsed.query}" if parsed.query else "" + fragment_part = f"#{parsed.fragment}" if parsed.fragment else "" + link = rel_link_path + query_part + fragment_part + parsed = urlparse(link) + else: + continue # External link else: - link = "/" + link[len(site_url_no_slash) :] - parsed = urlparse(link) + continue # External link path_part = parsed.path anchor_part = parsed.fragment @@ -185,7 +193,7 @@ def get_file_ids(path): # Resolve Target File if not path_part: - target_file = ROOT_DIR / "index.html" if is_absolute_internal else file_path + target_file = file_path elif path_part.startswith("/"): # Absolute path from root rel_path = path_part[1:] From 32c4f0fc770588db3ef4a7448539b64242c487ff Mon Sep 17 00:00:00 2001 From: damaz91 Date: Tue, 11 Aug 2026 15:50:35 +0000 Subject: [PATCH 3/3] fix(scripts): ignore versioned links if that version directory is not built --- scripts/check_links.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/scripts/check_links.py b/scripts/check_links.py index 9aa2e2cbd..0e102cf58 100644 --- a/scripts/check_links.py +++ b/scripts/check_links.py @@ -190,6 +190,7 @@ def get_file_ids(path): path_part = "/" + path_part[len(SITE_BASE_PATH) :] target_file = None + is_unbuilt_version = False # Resolve Target File if not path_part: @@ -211,7 +212,14 @@ def get_file_ids(path): ) and not (ROOT_DIR / parts[0]).exists() ): - rel_path = parts[1] + is_unbuilt_version = True + stripped_path = parts[1] + if ( + (ROOT_DIR / stripped_path).exists() + or (ROOT_DIR / (stripped_path + ".html")).exists() + or (ROOT_DIR / stripped_path / "index.html").exists() + ): + rel_path = stripped_path target_file = ROOT_DIR / rel_path else: @@ -232,11 +240,15 @@ def get_file_ids(path): if candidate.exists(): target_file = candidate else: + if is_unbuilt_version: + continue errors_by_version[version][str(file_path)].append( f" Link: {original_link}\n Target: {target_file} (Not Found)" ) continue else: + if is_unbuilt_version: + continue errors_by_version[version][str(file_path)].append( f" Link: {original_link}\n Target: {target_file} (Not Found)" )