Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tests/tools/test_api_urls_to_typescript.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
r"^(?P<organization_id_or_slug>[^/]+)/events/(?P<project_id_or_slug>[^/]+):(?P<event_id>(?:\d+|[A-Fa-f0-9-]{32,36}))/$",
["$organizationIdOrSlug/events/$projectIdOrSlug:$eventId/"],
),
# Escaped literal characters lose their backslash
(
r"^scm-git/repositories/(?P<repository_id>[0-9]{1,19})\.git/(?P<route>.+)$",
["scm-git/repositories/$repositoryId.git/$route"],
),
),
)
def test_regexp_to_route(input_regexp, expected) -> None:
Expand Down
3 changes: 3 additions & 0 deletions tools/api_urls_to_typescript.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Loading