From afccd8225fadfe4d4d5174dd8392f2ed0f0c8b32 Mon Sep 17 00:00:00 2001 From: Peter Hedenskog Date: Thu, 26 Mar 2020 19:44:09 +0100 Subject: [PATCH] Catch URLs that uses U+2013 that breaks Graphite (#2943) --- lib/support/flattenMessage.js | 3 ++- lib/support/tsdbUtil.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/support/flattenMessage.js b/lib/support/flattenMessage.js index cd29ef088..00f1ea33c 100644 --- a/lib/support/flattenMessage.js +++ b/lib/support/flattenMessage.js @@ -8,7 +8,8 @@ function joinNonEmpty(strings, delimeter) { } function toSafeKey(key) { - return key.replace(/[.~ /+|,:?&%)(]|%7C/g, '_'); + // U+2013 : EN DASH – as used on https://en.wikipedia.org/wiki/2019–20_coronavirus_pandemic + return key.replace(/[.~ /+|,:?&%–)(]|%7C/g, '_'); } module.exports = { diff --git a/lib/support/tsdbUtil.js b/lib/support/tsdbUtil.js index 20351f400..9fbf4a908 100644 --- a/lib/support/tsdbUtil.js +++ b/lib/support/tsdbUtil.js @@ -5,7 +5,7 @@ const flatten = require('./flattenMessage'); module.exports = { toSafeKey(key, safeChar = '_') { - return key.replace(/[.~ /+|,:?&%]|%7C/g, safeChar); + return key.replace(/[.~ /+|,:?&%–]|%7C/g, safeChar); }, getConnectivity(options) { // if we have a friendly name for your connectivity, use that!