From 455bebacd320e225ae177530ac8bd903f28bcf19 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$/, '');