fix(valid-detection-benchmark): normalize mixed-case .git suffixes in reservation identity

A reference such as OWNER/REPO.GIT escaped the reserved-identity check at both reservation sites because the suffix was stripped case-sensitively. One shared strip now handles the suffix case-insensitively; identities without a mixed-case suffix are byte-identical.
This commit is contained in:
Marius Ciepluch
2026-11-23 11:40:09 +01:00
parent f2093a5380
commit 7e6da2efae
4 changed files with 118 additions and 2 deletions
+9 -1
View File
@@ -11,6 +11,7 @@ from openultrasast.core.canonical import JsonValue, content_digest
NETWORK_SCHEMA = "openultrasast.valid-detection-benchmark.repository-network.v1"
_DIGEST = re.compile(r"[0-9a-f]{64}")
_GIT_SUFFIX = ".git"
class ReservationError(ValueError):
@@ -52,6 +53,13 @@ def _require_digest(value: object, field: str) -> str:
return value
def strip_git_suffix(repository: str) -> str:
"""Drop a trailing provider clone suffix in any letter case, nothing else."""
if repository.lower().endswith(_GIT_SUFFIX):
return repository[: len(repository) - len(_GIT_SUFFIX)]
return repository
def _repository_locator(value: object) -> str:
text = _require_text(value, "repository locator")
try:
@@ -67,7 +75,7 @@ def _repository_locator(value: object) -> str:
if len(parts) != 2:
raise ReservationError("repository locator must identify owner and repository")
owner, repository = parts
repository = repository.removesuffix(".git")
repository = strip_git_suffix(repository)
if not owner or not repository:
raise ReservationError("repository locator must identify owner and repository")
return f"https://{parsed.hostname.lower()}/{owner.lower()}/{repository.lower()}"