fix: handle windows paths in compression keys

This commit is contained in:
codingFeng101 2026-06-28 10:14:13 +08:00
parent cc57fe2111
commit 04408755df
2 changed files with 8 additions and 1 deletions

View file

@ -34,7 +34,7 @@ def extract_key(message: dict, fallback_index: int, used_keys: Set[str]) -> str:
if match:
# Use just the filename, not full path
path = match.group(1)
key = path.split("/")[-1]
key = re.split(r"[\\/]", path)[-1]
break
if key is None:

View file

@ -98,6 +98,13 @@ def test_extract_key_with_filename():
assert key == "auth.py"
def test_extract_key_with_windows_file_path():
msg = {"role": "user", "content": r"File: C:\repo\auth.py"}
used: set = set()
key = extract_key(msg, fallback_index=0, used_keys=used)
assert key == "auth.py"
def test_extract_key_fallback():
msg = {"role": "user", "content": "Some random content without a filename"}
used: set = set()