Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 95f24b0

Browse files
committed
Use split and join instead of regex for substitutions
1 parent 81e4e60 commit 95f24b0

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

lib/sepia/src/util.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ var path = require('path');
1818
var crypto = require('crypto');
1919
var fs = require('fs');
2020
var Levenshtein = require('levenshtein');
21-
var escapeRegex = require('escape-string-regexp');
2221

2322
const COLOR_RESET = '\033[0m';
2423
const COLOR_RED_BOLD = '\033[1;31m';
@@ -130,7 +129,7 @@ function substituteWithOpaqueKeys(text) {
130129
var substitutions = globalOptions.substitutions;
131130
for (var i=0; i<substitutions.length; i++) {
132131
var subst = substitutions[i];
133-
text = text.replace(new RegExp(escapeRegex(subst.actualValueFn()), 'g'), subst.opaqueKey);
132+
text = text.split(subst.actualValueFn()).join(subst.opaqueKey);
134133
}
135134
return text;
136135
}
@@ -139,7 +138,7 @@ function substituteWithRealValues(text) {
139138
var substitutions = globalOptions.substitutions;
140139
for (var i=0; i<substitutions.length; i++) {
141140
var subst = substitutions[i];
142-
text = text.replace(new RegExp(escapeRegex(subst.opaqueKey), 'g'), subst.actualValueFn());
141+
text = text.split(subst.opaqueKey).join(subst.actualValueFn());
143142
}
144143
return text;
145144
}

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
},
3737
"dependencies": {
3838
"colors": "^1.1.2",
39-
"escape-string-regexp": "1.0.5",
4039
"express": "^4.14.0",
4140
"http-proxy": "^1.15.2",
4241
"levenshtein": "^1.0.5",

0 commit comments

Comments
 (0)