From 47441a08653a6d8e63844c0da5e691b448b0cae9 Mon Sep 17 00:00:00 2001 From: Nick Gavalas Date: Tue, 7 Mar 2023 22:32:13 -0600 Subject: [PATCH] perf: swap order of escape regexes to avoid lookahead (#546) * swap regex order to avoid lookahead * changelog * changelog formatting apparently --- lib/registry.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/registry.js b/lib/registry.js index 127c659a..70d4f5ce 100644 --- a/lib/registry.js +++ b/lib/registry.js @@ -214,7 +214,7 @@ function escapeLabelValue(str) { return escapeString(str).replace(/"/g, '\\"'); } function escapeString(str) { - return str.replace(/\n/g, '\\n').replace(/\\(?!n)/g, '\\\\'); + return str.replace(/\\/g, '\\\\').replace(/\n/g, '\\n'); } function standardizeCounterName(name) { return name.replace(/_total$/, '');