Closed yannickrocks closed 2 years ago
Would you like to put a PR together with a unit test for this?
@willfarrell Working on it today.
We also have found a way to populate the path parameters if that is something people would be interested in.
PR is here @willfarrell https://github.com/middyjs/middy/pull/901
We also have found a way to populate the path parameters if that is something people would be interested in.
Can you open a new issue for this?
When used with API Gateway the pathParameters are pre-parsed which is why it's not included currently. This also giving a perf boost compared to other routers. Are you using this with ALB or Function URLs? Would love to heard more about your use case.
HI @willfarrell Sure thing, We are using Function URLs to allow lambdas to call other lambdas internally. :D
Describe the bug In the Http-Router package, the following will not resolve correctly to create dyanmic routes
E.g. Imagine you have 2 function URL with the following paths:
/varA/{varA}/varB/{varB}
/varA/{varA}/varC/{varC}
The line of code
path = path.replace(regexpDynamicWildcards, '/?.*').replace(regexpDynamicParameters, '/.+')
will resolve both paths to/^\/varA\/.+$/
This is an issue as if you are trying to use the second path, it will use the first path's parameters which can cause issues further down the line.
THE FIX
change the following
OLD
NEW
Regex helper: https://regex101.com/r/Xk1x6P/1