🎨 small webhook refactorings (#1383)

* 🧹 clean up forgotten leftover

* 🎨 reset req.params

* 🐛 Bugfix and minor change on request parameters

*  Minor improvements on request parameters

Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
Ben Hesseldieck
2021-01-28 15:44:10 +01:00
committed by GitHub
parent bc74d7ad47
commit 8764171989
3 changed files with 10 additions and 11 deletions

View File

@@ -56,6 +56,9 @@ export class 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 = {};
// check if path is dynamic
if (webhookData === undefined) {
const pathElements = path.split('/');
@@ -65,6 +68,7 @@ export class TestWebhooks {
// The requested webhook is not registered
throw new ResponseHelper.ResponseError(`The requested webhook "${httpMethod} ${path}" is not registered.`, 404, 404);
}
path = webhookData.path;
// extracting params from path
path.split('/').forEach((ele, index) => {