diff --git a/CHANGELOG.md b/CHANGELOG.md index bc9c0bf0..2fff6eb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ project adheres to [Semantic Versioning](http://semver.org/). ### Changed +- Refactor `escapeString` helper in `lib/registry.js` to improve performance and + avoid an unnecessarily complex regex. + ### Added ## [14.2.0] - 2023-03-06 diff --git a/lib/registry.js b/lib/registry.js index 9b656d03..f139fc50 100644 --- a/lib/registry.js +++ b/lib/registry.js @@ -2,7 +2,7 @@ const { getValueAsString } = require('./util'); function escapeString(str) { - return str.replace(/\n/g, '\\n').replace(/\\(?!n)/g, '\\\\'); + return str.replace(/\\/g, '\\\\').replace(/\n/g, '\\n'); } function escapeLabelValue(str) { if (typeof str !== 'string') {