FIX: Obscure emoji fail with a colon surrounded by spaces

This commit is contained in:
Robin Ward 2014-06-09 14:44:34 -04:00
parent 9d96fc6370
commit a63ac64931
2 changed files with 6 additions and 14 deletions

View file

@ -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;

View file

@ -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"), "/");
});