From 0657ffd3892a93df49c11d424e43b0eee15ec6bd Mon Sep 17 00:00:00 2001 From: luanvcmartins <33265148+luanvcmartins@users.noreply.github.com> Date: Sat, 18 Nov 2017 15:56:45 -0200 Subject: [PATCH] Fixed event ID regex Passing a valid event ID always returns "Invalid event ID" due to broken verification, making impossible to update events. While an AIDAX's key (uuid) expects the 15th character to be a "4", a valid event ID contains the constant "5" on the 15th position, making the validate_uuid unable to correctly validade an event's ID. --- src/client.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/client.js b/src/client.js index 9787934..3b11ccc 100644 --- a/src/client.js +++ b/src/client.js @@ -212,6 +212,10 @@ var AIDAX_COLLECTOR = "//api.aidax.com.br", var uuid_regex = /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i; return uuid_regex.test(id); }, + validate_eventid = function(event_id){ + var eid_regex = /^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i; + return eid_regex.test(event_id); + }, href = getHref(), referer = getReferrer(), device = UAParser(), @@ -407,7 +411,7 @@ var uid = aidax_visitor_id, ); var cond2 = assert( typeof obj.id === "undefined" || - (typeof obj.id === "string" && validate_uuid(obj.id)), + (typeof obj.id === "string" && validate_eventid(obj.id)), "[AIDAX] Invalid event ID." ); if(cond1 && cond2) {