2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-28 03:26:45 +00:00

Improve handling for raw github repo links (#8483)

* Improve handling for raw github repo links

* Fix strict mode
This commit is contained in:
Oliver 2024-11-14 13:55:46 +11:00 committed by GitHub
parent 246f17113f
commit b1a5b1a3bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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