Empty character in regex not getting matched
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 22.9k
- Forks
- 1.4k
- Avg merge
- 5h 17m
- Merged PRs (30d)
- 10
Description
Hey there,
In https://github.com/go-chi/chi/pull/224, a check was added to short-circuit and return no matching route if the param value is empty.
I am trying the following regex in the router configuration to optionally match a route with an extension:
/v1/resource/done{:(^$|.json)} to match either /v1/resource/done.json or /v1/resource/done
Since the short-circuit kicks in because of the empty param value, the URL /v1/resource/done never matches that regex. Is there any other way to accomplish the same?
Thanks!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing PR #224 and the router's parameter-matching path for the route pattern /v1/resource/done{:(^$|.json)}. Reproduce matching both /v1/resource/done.json and /v1/resource/done; done means the empty parameter is handled consistently with the regex and both intended routes are covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100