dd-trace-go
dd-trace-go copied to clipboard
[BUG] contrib/dimfeld/httptreemux.v5: default resource namer incorrectly replaces path variables
Version of dd-trace-go
v1.65.1
Describe what happened:
The default resource name in the contrib/dimfeld/httptreemux.v5 package has a bug where the path variable replacement fails under certain conditions.
E.g. if you have a route /foo/2by4/bar/:n and request path /foo/2by4/2 then the code will attempt to replace the first occurrence of /2 with /:n which will result in the path: /foo/:nby4/2.
Describe what you expected:
The code should replace the correct variable and leave the rest of the path unaltered.
Steps to reproduce the issue:
- Include the router in a project.
- Register a handler for an endpoint, eg.
GET /foo/2by4/bar/:n - Call the endpoint with the following:
GET /foo/2by4/2
Additional environment details (Version of Go, Operating System, etc.):
Thanks for reaching out. We'll review this and fix the issue.