From 0044a990009dd7afdd967036e64d56c7cdedd0b2 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 7 Nov 2014 12:04:24 -0500 Subject: [PATCH] Don't raise an error for global regexps; warn the plugin author instead. --- app/assets/javascripts/discourse/lib/markdown.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/lib/markdown.js b/app/assets/javascripts/discourse/lib/markdown.js index bca52061e8d..8f57adcfb97 100644 --- a/app/assets/javascripts/discourse/lib/markdown.js +++ b/app/assets/javascripts/discourse/lib/markdown.js @@ -1,4 +1,4 @@ -/*global Markdown:true */ +/*global Markdown, console */ /** Contains methods to help us with markdown formatting. @@ -83,7 +83,13 @@ function anchorRegexp(regex) { } var flags = ""; - if (regex.global) { throw "Invalid attribute validation regex - cannot be global"; } + if (regex.global) { + flags += "g"; + if (typeof console !== 'undefined') { + console.warn("attribute validation regex should not be global"); + } + } + if (regex.ignoreCase) { flags += "i"; } if (regex.multiline) { flags += "m"; } if (regex.sticky) { throw "Invalid attribute validation regex - cannot be sticky"; }