From 0a68b48acc956ab7e9b9b6e869b14e6f5e7d78e9 Mon Sep 17 00:00:00 2001 From: Esther Lozano Date: Wed, 26 Feb 2020 17:58:32 +0100 Subject: [PATCH] Avoid normalizing empty fields (#645) --- lib/api/middlewares/pubsub-metrics.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/api/middlewares/pubsub-metrics.js b/lib/api/middlewares/pubsub-metrics.js index 1f459a1c..f5410a03 100644 --- a/lib/api/middlewares/pubsub-metrics.js +++ b/lib/api/middlewares/pubsub-metrics.js @@ -45,6 +45,10 @@ function getEventData (req, res) { } function normalizedField (field) { + if (!field) { + return undefined; + } + return field.toString().trim().substr(0, MAX_LENGTH); }