FIX: slightly improve emoji support in titles (no need for spaces between emojis)
This commit is contained in:
parent
f26eee8431
commit
01a23203c7
|
@ -9,7 +9,7 @@ const Topic = RestModel.extend({
|
|||
let title = this.get("fancy_title");
|
||||
|
||||
if (Discourse.SiteSettings.enable_emoji && title.indexOf(":") >= 0) {
|
||||
title = title.replace(/:\S+:?/g, function(m) {
|
||||
title = title.replace(/:[^\s:]+:?/g, function(m) {
|
||||
const emoji = Discourse.Emoji.translations[m] ? Discourse.Emoji.translations[m] : m.slice(1, m.length - 1),
|
||||
url = Discourse.Emoji.urlFor(emoji);
|
||||
return url ? "<img src='" + url + "' title='" + emoji + "' alt='" + emoji + "' class='emoji'>" : m;
|
||||
|
|
|
@ -73,6 +73,8 @@ test("recover", function() {
|
|||
});
|
||||
|
||||
test('fancyTitle', function() {
|
||||
var topic = Topic.create({ fancy_title: ":smile: with all the emojis" });
|
||||
equal(topic.get('fancyTitle'), "<img src='/images/emoji/undefined/smile.png?v=0' title='smile' alt='smile' class='emoji'> with all the emojis", "supports emojis");
|
||||
var topic = Topic.create({ fancy_title: ":smile: with all :) the emojis :pear::peach:" });
|
||||
equal(topic.get('fancyTitle'),
|
||||
"<img src='/images/emoji/undefined/smile.png?v=0' title='smile' alt='smile' class='emoji'> with all <img src='/images/emoji/undefined/smile.png?v=0' title='smile' alt='smile' class='emoji'> the emojis <img src='/images/emoji/undefined/pear.png?v=0' title='pear' alt='pear' class='emoji'><img src='/images/emoji/undefined/peach.png?v=0' title='peach' alt='peach' class='emoji'>",
|
||||
"supports emojis");
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue