Check if the hashtag is a link in function .hashtagify
This commit is contained in:
parent
a51c4f0ddc
commit
7c4d783d51
2 changed files with 17 additions and 5 deletions
|
|
@ -108,11 +108,16 @@ $(function() {
|
|||
};
|
||||
|
||||
textFormatter.hashtagify = function hashtagify(text){
|
||||
var utf8WordCharcters =/(\s|^|>)#([\u0080-\uFFFF|\w|-]+|<3)/g
|
||||
var utf8WordCharcters =/(\s|^|>)#([\u0080-\uFFFF|\w|-]+|<3)/g;
|
||||
var linkRegex = /<a[^>]*>(.*?)<\/a>/g;
|
||||
|
||||
if(text.match(linkRegex))
|
||||
return text;
|
||||
else
|
||||
return text.replace(utf8WordCharcters, function(hashtag, preceeder, tagText) {
|
||||
return preceeder + "<a href='/tags/" + tagText.toLowerCase() +
|
||||
"' class='tag'>#" + tagText + "</a>"
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
textFormatter.mentionify = function mentionify(text, mentions) {
|
||||
|
|
|
|||
|
|
@ -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 = $('<a/>', { href: 'http://me.co' }).html('#me')[0].outerHTML;
|
||||
var result = this.formatter.hashtagify(link);
|
||||
|
||||
expect(result).toEqual(link);
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue