This commit is contained in:
2025-09-07 22:09:54 +02:00
parent e1b817252c
commit 2fc0d000b6
7796 changed files with 2159515 additions and 933 deletions

View File

@ -0,0 +1,25 @@
import re
cache_regex = re.compile(r"^v[\w-]+m[0-9a-fA-F]+$")
version_clean = re.compile(r"[^\w-]")
def build_fingerprint(path, version, hash_value):
path_parts = path.split("/")
filename, extension = path_parts[-1].split(".", 1)
file_path = "/".join(path_parts[:-1] + [filename])
v_str = re.sub(version_clean, "_", str(version))
return f"{file_path}.v{v_str}m{hash_value}.{extension}"
def check_fingerprint(path):
path_parts = path.split("/")
name_parts = path_parts[-1].split(".")
# Check if the resource has a fingerprint
if len(name_parts) > 2 and cache_regex.match(name_parts[1]):
original_name = ".".join([name_parts[0]] + name_parts[2:])
return "/".join(path_parts[:-1] + [original_name]), True
return path, False