diff --git a/app/assets/javascripts/app/helpers/text_formatter.js b/app/assets/javascripts/app/helpers/text_formatter.js
index 3e122d87a..0ae8e9d5d 100644
--- a/app/assets/javascripts/app/helpers/text_formatter.js
+++ b/app/assets/javascripts/app/helpers/text_formatter.js
@@ -108,11 +108,16 @@ $(function() {
};
textFormatter.hashtagify = function hashtagify(text){
- var utf8WordCharcters =/(\s|^|>)#([\u0080-\uFFFF|\w|-]+|<3)/g
- return text.replace(utf8WordCharcters, function(hashtag, preceeder, tagText) {
- return preceeder + "#" + tagText + ""
- })
+ var utf8WordCharcters =/(\s|^|>)#([\u0080-\uFFFF|\w|-]+|<3)/g;
+ var linkRegex = /]*>(.*?)<\/a>/g;
+
+ if(text.match(linkRegex))
+ return text;
+ else
+ return text.replace(utf8WordCharcters, function(hashtag, preceeder, tagText) {
+ return preceeder + "#" + tagText + ""
+ });
};
textFormatter.mentionify = function mentionify(text, mentions) {
diff --git a/spec/javascripts/app/helpers/text_formatter_spec.js b/spec/javascripts/app/helpers/text_formatter_spec.js
index 29aec511e..2c1461b69 100644
--- a/spec/javascripts/app/helpers/text_formatter_spec.js
+++ b/spec/javascripts/app/helpers/text_formatter_spec.js
@@ -238,6 +238,13 @@ describe("app.helpers.textFormatter", function(){
expect(formattedText).toContain("/tags/parties")
})
+
+ it("doesn't create tag if the text is a link", function(){
+ var link = $('', { href: 'http://me.co' }).html('#me')[0].outerHTML;
+ var result = this.formatter.hashtagify(link);
+
+ expect(result).toEqual(link);
+ })
})
})