Stelle den Frontend-MVP und die v0.3-API auf develop bereit, damit Dev API und PWA zusammen deployen.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
827e6a2a11
commit
b276758ee1
152 files changed
+25846
-34
No files matched your search
@@ -0,0 +1,34 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
from urllib.parse import parse_qsl, urlsplit
|
||||
|
||||
from app.discovery.enums import MappingStatus
|
||||
from app.discovery.urlgen import decode_xf_roundtrip, generate_search_url
|
||||
|
||||
|
||||
def verify_roundtrip(
|
||||
*,
|
||||
category_url: str,
|
||||
criterion: dict[str, Any],
|
||||
mapping: dict[str, Any],
|
||||
) -> bool:
|
||||
"""True when encoding a single mapping round-trips to the same source parameter."""
|
||||
probe = {**mapping, "status": MappingStatus.VERIFIED.value}
|
||||
url, internal = generate_search_url(
|
||||
category_url=category_url,
|
||||
criteria_items=[criterion],
|
||||
mappings=[probe],
|
||||
)
|
||||
if internal:
|
||||
return False
|
||||
encoding = mapping.get("encoding") or {}
|
||||
param = str(encoding.get("url_param") or "xf")
|
||||
if param == "xf":
|
||||
expected_key = str(mapping["external_filter_key"])
|
||||
expected_value = str(mapping.get("source_value") or "")
|
||||
decoded = decode_xf_roundtrip(url)
|
||||
return any(key == expected_key and value == expected_value.replace("+", " ") for key, value in decoded)
|
||||
expected = str(criterion.get("value"))
|
||||
query = parse_qsl(urlsplit(url).query, keep_blank_values=True)
|
||||
return any(name == param and value == expected for name, value in query)
|
||||
Reference in new issue
Block a user