Dynamic webhooks improvements (#1396)

*  remove trailing slash in routes

* 🔧 update logic to select dynamicWebhook

* 🐛 fix logic in static route matching
This commit is contained in:
Ben Hesseldieck
2021-02-09 09:14:40 +01:00
committed by GitHub
parent 7a3aaf8a24
commit 98fa529e51
4 changed files with 61 additions and 43 deletions

View File

@@ -54,11 +54,16 @@ export class TestWebhooks {
* @memberof TestWebhooks
*/
async callTestWebhook(httpMethod: WebhookHttpMethod, path: string, request: express.Request, response: express.Response): Promise<IResponseCallbackData> {
let webhookData: IWebhookData | undefined = this.activeWebhooks!.get(httpMethod, path);
// Reset request parameters
request.params = {};
// Remove trailing slash
if (path.endsWith('/')) {
path = path.slice(0, -1);
}
let webhookData: IWebhookData | undefined = this.activeWebhooks!.get(httpMethod, path);
// check if path is dynamic
if (webhookData === undefined) {
const pathElements = path.split('/');