Solution: add negative lookahead to prevent matching the criteria at the very end of the endpoint path. This ensures that any of the criteria regex strings is NOT matched as filter parameter when it is the end of the endpoint path. Currently, the router matches the end of the string as a filter parameter as well and then fails to determine the actual endpoint because the full path has been "matched away".
One remaining difference is that this still redirect .../circuits/monza to .../circuits/monza/ with a 301 response, adding the trailing slash. But only the endpoint without trailing slash is valid in Ergast. I'd say this is irrelevant, because the HTML interface is only used through a browser by humans and this will not cause any problems.
Contributing Checklist
[x] Unit tests for the changes are included in this PR.
Why are you making this change?
Fix #50
Note that the problem is not specific to the
/circuits
endpoint but it is relevant for all endpoints that can also be used as filters.Example endpoints that are currently broken as HTML but work as JSON:
Solution: add negative lookahead to prevent matching the criteria at the very end of the endpoint path. This ensures that any of the criteria regex strings is NOT matched as filter parameter when it is the end of the endpoint path. Currently, the router matches the end of the string as a filter parameter as well and then fails to determine the actual endpoint because the full path has been "matched away".
One remaining difference is that this still redirect
.../circuits/monza
to.../circuits/monza/
with a 301 response, adding the trailing slash. But only the endpoint without trailing slash is valid in Ergast. I'd say this is irrelevant, because the HTML interface is only used through a browser by humans and this will not cause any problems.Contributing Checklist