From b1a5b1a3bb8ca6e9ee6ca047e73bf75d288a840f Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 14 Nov 2024 13:55:46 +1100 Subject: [PATCH] Improve handling for raw github repo links (#8483) * Improve handling for raw github repo links * Fix strict mode --- docs/main.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/main.py b/docs/main.py index 84b91f7ad8..97b28c98cc 100644 --- a/docs/main.py +++ b/docs/main.py @@ -151,17 +151,19 @@ def define_env(env): if not os.path.exists(file_path): raise FileNotFoundError(f'Source file {filename} does not exist.') - repo_url = get_repo_url(raw=raw) - - if raw: - url = f'{repo_url}/{branch}/{filename}' - else: - url = f'{repo_url}/blob/{branch}/{filename}' + # Construct repo URL + repo_url = get_repo_url(raw=False) + url = f'{repo_url}/blob/{branch}/{filename}' # Check that the URL exists before returning it if not check_link(url): raise FileNotFoundError(f'URL {url} does not exist.') + if raw: + # If requesting the 'raw' URL, take this into account here... + repo_url = get_repo_url(raw=True) + url = f'{repo_url}/{branch}/{filename}' + return url @env.macro