FIX: Avoid using RegExp flag s.

FIX: Avoid using RegExp flag s.

diff --git a/assets/javascripts/discourse/initializers/checklist.js.es6 b/assets/javascripts/discourse/initializers/checklist.js.es6
index e073da0..2df3928 100644
--- a/assets/javascripts/discourse/initializers/checklist.js.es6
+++ b/assets/javascripts/discourse/initializers/checklist.js.es6
@@ -38,8 +38,8 @@ export function checklistSyntax($elem, post) {
           // code blocks).
           [
             /`[^`\n]*\n?[^`\n]*`/gm,
-            /^`‍``.*?^`‍``/gms,
-            /\[code\].*?\[\/code\]/gms
+            /^`‍``[^]*?^`‍``/gm,
+            /\[code\][^]*?\[\/code\]/gm
           ].forEach(regex => {
             let match;
             while ((match = regex.exec(result.raw)) != null) {
diff --git a/test/javascripts/lib/checklist-test.js.es6 b/test/javascripts/lib/checklist-test.js.es6
index b927861..b66e69d 100644
--- a/test/javascripts/lib/checklist-test.js.es6
+++ b/test/javascripts/lib/checklist-test.js.es6
@@ -8,6 +8,15 @@ QUnit.test("correct checkbox is selected", assert => {
 
 It seems that a code block followed by a checklist breaks things.
 
+\`[x]\`
+
+[code]
+[\*]
+[ ]
+[ ]
+[\*]
+[/code]
+
 \`\`\`
 [\*]
 [ ]
@@ -25,6 +34,12 @@ Clicking the boxes will ruin the code block and the list becomes unresponsive.`;
   const cooked = `<div class="cooked">
 <p>Hi there,</p>
 <p>It seems that a code block followed by a checklist breaks things.</p>
+<pre>[*]</pre>
+<pre><code>[\*]
+[ ]
+[ ]
+[\*]
+</code></pre>
 <pre><code>[\*]
 [ ]
 [ ]

GitHub sha: 0250bd1c

1 Like