@contrail/util 1.0.29 → 1.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,6 +5,7 @@ function replaceAllWithFunction(string, regEx, replacerFunction) {
|
|
|
5
5
|
let match;
|
|
6
6
|
let newString = '';
|
|
7
7
|
let startIndex = 0;
|
|
8
|
+
let hasMatches = false;
|
|
8
9
|
while ((match = regEx.exec(string)) !== null) {
|
|
9
10
|
let matchedString = match[0];
|
|
10
11
|
let index = match.index;
|
|
@@ -12,6 +13,10 @@ function replaceAllWithFunction(string, regEx, replacerFunction) {
|
|
|
12
13
|
newString += string.substring(startIndex, index);
|
|
13
14
|
newString += newValue;
|
|
14
15
|
startIndex += index + matchedString.length;
|
|
16
|
+
hasMatches = true;
|
|
17
|
+
}
|
|
18
|
+
if (!(newString === null || newString === void 0 ? void 0 : newString.length) && !hasMatches) {
|
|
19
|
+
newString = string;
|
|
15
20
|
}
|
|
16
21
|
return newString;
|
|
17
22
|
}
|