Skip to content

Commit d78b737

Browse files
fix: polifilled replaceAll
1 parent 28667f8 commit d78b737

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib-es5/utils/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,14 @@ function process_layer(layer) {
326326
return components.join(':');
327327
}
328328

329+
function replaceAllSubstrings(string, search) {
330+
var replacement = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
331+
332+
return string.split(search).join(replacement);
333+
}
334+
329335
function encodeCurlyBraces(input) {
330-
return input.replaceAll('(', '%28').replaceAll(')', '%29');
336+
return replaceAllSubstrings(replaceAllSubstrings(input, '(', '%28'), ')', '%29');
331337
}
332338

333339
/**

lib/utils/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,12 @@ function process_layer(layer) {
308308
return components.join(':');
309309
}
310310

311+
function replaceAllSubstrings(string, search, replacement = '') {
312+
return string.split(search).join(replacement);
313+
}
314+
311315
function encodeCurlyBraces(input) {
312-
return input.replaceAll('(', '%28').replaceAll(')', '%29');
316+
return replaceAllSubstrings(replaceAllSubstrings(input, '(', '%28'), ')', '%29');
313317
}
314318

315319
/**

0 commit comments

Comments
 (0)