Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: polyfill `String.prototype.replaceAll` (#14754)

boojackc01adfd65274
diff --git a/frontend/src/main.ts b/frontend/src/main.ts
index 2a19e3ae9d..a9be5d0578 100644
--- a/frontend/src/main.ts
+++ b/frontend/src/main.ts
@@ -12,6 +12,7 @@ import highlight from "./plugins/highlight";
import i18n from "./plugins/i18n";
import NaiveUI from "./plugins/naive-ui";
import { isSilent } from "./plugins/silent-request";
+import "./polyfill";
import { router } from "./router";
import { pinia, pushNotification } from "./store";
import {
diff --git a/frontend/src/polyfill.ts b/frontend/src/polyfill.ts
new file mode 100644
index 0000000000..47671b9a2e
--- /dev/null
+++ b/frontend/src/polyfill.ts
@@ -0,0 +1,21 @@
+(() => {
+ if (!String.prototype.replaceAll) {
+ String.prototype.replaceAll = function (
+ search: string | RegExp,
+ replacement: any
+ ) {
+ if (search instanceof RegExp) {
+ if (!search.flags.includes("g")) {
+ throw new TypeError("replaceAll must be called with a global RegExp");
+ }
+ return this.replace(search, replacement);
+ } else {
+ const escapedSearch = search.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
+ const regex = new RegExp(escapedSearch, "g");
+ return this.replace(regex, replacement);
+ }
+ };
+ }
+})();
+
+export default null;