Skip to content

Commit

Permalink
Fixes #119. emoji with number underscore dash or plus ignored.
Browse files Browse the repository at this point in the history
  • Loading branch information
donthorp committed Feb 26, 2013
1 parent bcf746c commit 25cb0f7
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions app/assets/javascripts/backbone/plugins/emoticons.js.coffee
@@ -1,7 +1,7 @@
class Kandan.Plugins.Emoticons

@options:
regex: /\([a-zA-Z]+\)|(:[a-z]+:)|(^|\s)+([:|=][\)|\(|P|p])($|\s)/g
regex: /\([a-zA-Z]+\)|(:[\w\-+]+:)|(^|\s)+([:|=][\)|\(|P|p])($|\s)/g
template: _.template '''
<img class="emoticon-embed <%= css %>" src="/assets/emoticons/<%= src %>" title="<%= title %>" />
'''
Expand Down Expand Up @@ -910,12 +910,9 @@ class Kandan.Plugins.Emoticons
matches = message.content.match(@options.regex)
for match in _.unique(matches)
match = match.trim();
emoticon = @emoticons[match]
emoticon = @emoticons[match]

if emoticon
needle = match.replace('(', '\\(').replace(')', '\\)')
search = new RegExp(needle, 'g')
replacement = @options.template(emoticon)
message.content = message.content.replace(search, replacement)
message.content = message.content.replace(match, @options.template(emoticon))

return Kandan.Helpers.Activities.buildFromMessageTemplate(message)

0 comments on commit 25cb0f7

Please sign in to comment.