diff --git a/tests/tools/test_api_urls_to_typescript.py b/tests/tools/test_api_urls_to_typescript.py index dc5532d5ab21..70a7728ba9e0 100644 --- a/tests/tools/test_api_urls_to_typescript.py +++ b/tests/tools/test_api_urls_to_typescript.py @@ -34,6 +34,11 @@ r"^(?P[^/]+)/events/(?P[^/]+):(?P(?:\d+|[A-Fa-f0-9-]{32,36}))/$", ["$organizationIdOrSlug/events/$projectIdOrSlug:$eventId/"], ), + # Escaped literal characters lose their backslash + ( + r"^scm-git/repositories/(?P[0-9]{1,19})\.git/(?P.+)$", + ["scm-git/repositories/$repositoryId.git/$route"], + ), ), ) def test_regexp_to_route(input_regexp, expected) -> None: diff --git a/tools/api_urls_to_typescript.py b/tools/api_urls_to_typescript.py index b8e3c9fe5c3a..487b333e09dd 100644 --- a/tools/api_urls_to_typescript.py +++ b/tools/api_urls_to_typescript.py @@ -152,6 +152,9 @@ def replace_named_group(match: re.Match[str]) -> str: # Handle optional trailing slash route = re.sub(r"/\?$", "/", route) + # Unescape literal characters like \. so the route holds the character itself + route = re.sub(r"\\([^\w\s])", r"\1", route) + # Clean up any double slashes that might have been created route = re.sub(r"/+", "/", route)