From c0b8834c8ceb4c5ac5de8621288cc9ba06d9396b Mon Sep 17 00:00:00 2001 From: micodix <80091840+micodix@users.noreply.github.com> Date: Thu, 13 Oct 2022 22:03:08 +0200 Subject: [PATCH] added case-insensitive ActionID support --- lib/ami.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/ami.js b/lib/ami.js index ab6b5f6..af15167 100644 --- a/lib/ami.js +++ b/lib/ami.js @@ -294,14 +294,17 @@ function ManagerAction(context, action, callback) { action = action || {}; callback = Utils.defaultCallback(callback); - var id = action.actionid || String((new Date()).getTime()); + var id = String((new Date()).getTime()); + // find case insensitive occurence of property 'actionid' (e.g. 'ActionID' could have been set) + var idMatch = Object.keys(action).join().match(/(.+,)?(actionid)(,.+)?/i); + if (idMatch != null) { + id = action[idMatch[2]]; + delete action[idMatch[2]]; + } while (this.listeners(id).length) id += String(Math.floor(Math.random() * 9)); - if (action.actionid) - delete action.actionid; - if (!context.authenticated && (action.action !== 'login')) { context.held = context.held || []; action.actionid = id;