From a63ac64931c90bf0033742f30cadad7681339574 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 9 Jun 2014 14:44:34 -0400 Subject: [PATCH] FIX: Obscure emoji fail with a colon surrounded by spaces --- plugins/emoji/assets/javascripts/emoji.js.erb | 14 ++++++-------- .../components/home_logo_component_test.js | 6 ------ 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/plugins/emoji/assets/javascripts/emoji.js.erb b/plugins/emoji/assets/javascripts/emoji.js.erb index ec4038d77..7d2ed8e89 100644 --- a/plugins/emoji/assets/javascripts/emoji.js.erb +++ b/plugins/emoji/assets/javascripts/emoji.js.erb @@ -64,11 +64,9 @@ return s.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&') } - var translationColonRegexp = new RegExp("^" + - Object.keys(translationsWithColon).map(function (t) { + var translationColonRegexp = new RegExp(Object.keys(translationsWithColon).map(function (t) { return "(" + escapeRegExp(t) + ")"; - }).join("|") - ); + }).join("|")); Discourse.Dialect.registerInline(':', function(text, match, prev) { var endPos = text.indexOf(':', 1), @@ -80,11 +78,11 @@ // If there is no trailing colon, check our translations that begin with colons if (endPos === -1 || (firstSpace !== -1 && endPos > firstSpace)) { translationColonRegexp.lastIndex = 0; - var match = translationColonRegexp.exec(text); - if (match && match[0]) { - contents = imageFor(translationsWithColon[match[0]]); + var m = translationColonRegexp.exec(text); + if (m && m[0] && text.indexOf(m[0]) === 0) { + contents = imageFor(translationsWithColon[m[0]]); if (contents) { - return [match[0].length, contents]; + return [m[0].length, contents]; } } return; diff --git a/test/javascripts/components/home_logo_component_test.js b/test/javascripts/components/home_logo_component_test.js index 8063d36a4..c6b884322 100644 --- a/test/javascripts/components/home_logo_component_test.js +++ b/test/javascripts/components/home_logo_component_test.js @@ -131,9 +131,3 @@ test("dynamically toggles logo size when 'minimized' property changes", function setMinimized(false); ok(exists(fixture(bigLogoSelector)), "when 'minimized' version is turned off, small logo is replaced with the big one"); }); - -test("links logo to the site root", function() { - appendView(); - - equal(fixture(".title > a").attr("href"), "/"); -});