about summary refs log tree commit diff
path: root/app/javascript/glitch/util
diff options
context:
space:
mode:
authorkibigo! <marrus-sh@users.noreply.github.com>2017-08-06 15:08:13 -0700
committerkibigo! <marrus-sh@users.noreply.github.com>2017-08-06 15:10:06 -0700
commit70c5eccc12558f27469ce09eee45762517dfe5fc (patch)
treebf2ccc3a248036f3a1ea8c160a07602103060c9f /app/javascript/glitch/util
parenteb7fc34708e7e31bcce559801563ff497595c247 (diff)
Compatibility regex for user profiles
Diffstat (limited to 'app/javascript/glitch/util')
-rw-r--r--app/javascript/glitch/util/bio_metadata.js16
1 files changed, 13 insertions, 3 deletions
diff --git a/app/javascript/glitch/util/bio_metadata.js b/app/javascript/glitch/util/bio_metadata.js
index 0c8195e9d..eb3ad01fe 100644
--- a/app/javascript/glitch/util/bio_metadata.js
+++ b/app/javascript/glitch/util/bio_metadata.js
@@ -74,17 +74,27 @@ functions are:
 
 \*********************************************************************/
 
+/*  "u" FLAG COMPATABILITY  */
+
+let compat_mode = false;
+try {
+  new RegExp('.', 'u');
+} catch (e) {
+  compat_mode = true;
+}
+
 /*  CONVENIENCE FUNCTIONS  */
 
-const unirex = str => new RegExp(str, 'u');
+const unirex = str => compat_mode ? new RegExp(str) : new RegExp(str, 'u');
 const rexstr = exp => '(?:' + exp.source + ')';
 
 /*  CHARACTER CLASSES  */
 
 const DOCUMENT_START    = /^/;
 const DOCUMENT_END      = /$/;
-const ALLOWED_CHAR      =  //  `c-printable` in the YAML 1.2 spec.
-  /[\t\n\r\x20-\x7e\x85\xa0-\ud7ff\ue000-\ufffd\u{10000}-\u{10FFFF}]/u;
+const ALLOWED_CHAR      =  unirex( //  `c-printable` in the YAML 1.2 spec.
+    compat_mode ? '[\t\n\r\x20-\x7e\x85\xa0-\ufffd]' : '[\t\n\r\x20-\x7e\x85\xa0-\ud7ff\ue000-\ufffd\u{10000}-\u{10FFFF}]'
+  );
 const WHITE_SPACE       = /[ \t]/;
 const INDENTATION       = / */;  //  Indentation must be only spaces.
 const LINE_BREAK        = /\r?\n|\r|<br\s*\/?>/;