Skip to content

Commit

Permalink
perf: swap order of escape regexes to avoid lookahead (#546)
Browse files Browse the repository at this point in the history
* swap regex order to avoid lookahead

* changelog

* changelog formatting apparently
  • Loading branch information
ngavalas authored and SimenB committed Mar 9, 2023
1 parent a19a1ad commit 84fae84
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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$/, '');
Expand Down

0 comments on commit 84fae84

Please sign in to comment.