Skip to content

A platform for community discussion. Free, open, simple.

FIX: prevents exception in the composer with regexp flags

Joffrey JAFFEUX5768011cad2e
diff --git a/app/assets/javascripts/polyfills.js b/app/assets/javascripts/polyfills.js
index a4a90dfe2c5..ab97aebb351 100644
--- a/app/assets/javascripts/polyfills.js
+++ b/app/assets/javascripts/polyfills.js
@@ -179,4 +179,14 @@ if (!Array.prototype.find) {
});
}
+// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/flags#Polyfill
+if (RegExp.prototype.flags === undefined) {
+ Object.defineProperty(RegExp.prototype, "flags", {
+ configurable: true,
+ get: function() {
+ return this.toString().match(/[gimsuy]*$/)[0];
+ }
+ });
+}
+
/* eslint-enable */