Skip to content
Extraits de code Groupes Projets
Valider 06ab4986 rédigé par Jonne Haß's avatar Jonne Haß
Parcourir les fichiers

Merge pull request #4847 from hincupetru/3692-hashtags-inside-markdown-link

Solved problem with hashtags inside markdown links
parents 3c4d8d95 7c4d783d
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
* Fixed Atom Feed Error if reshared Post is deleted [#4638] (https://github.com/diaspora/diaspora/issues/4638) * Fixed Atom Feed Error if reshared Post is deleted [#4638] (https://github.com/diaspora/diaspora/issues/4638)
* Show hovercards in the notification drop-down for users on the same pod [#4843](https://github.com/diaspora/diaspora/pull/4843) * Show hovercards in the notification drop-down for users on the same pod [#4843](https://github.com/diaspora/diaspora/pull/4843)
* The photo stream no longer repeats after the last photo [#4726](https://github.com/diaspora/diaspora/issues/4726) * The photo stream no longer repeats after the last photo [#4726](https://github.com/diaspora/diaspora/issues/4726)
* Stop parsing hashtags inside markdown links [#3692](https://github.com/diaspora/diaspora/issues/3692)
## Features ## Features
* You can report a single post by clicking the correct icon in the controler section [#4517](https://github.com/diaspora/diaspora/pull/4517) * You can report a single post by clicking the correct icon in the controler section [#4517](https://github.com/diaspora/diaspora/pull/4517)
......
...@@ -108,11 +108,16 @@ $(function() { ...@@ -108,11 +108,16 @@ $(function() {
}; };
textFormatter.hashtagify = function hashtagify(text){ textFormatter.hashtagify = function hashtagify(text){
var utf8WordCharcters =/(\s|^|>)#([\u0080-\uFFFF|\w|-]+|<3)/g var utf8WordCharcters =/(\s|^|>)#([\u0080-\uFFFF|\w|-]+|<3)/g;
return text.replace(utf8WordCharcters, function(hashtag, preceeder, tagText) { var linkRegex = /<a[^>]*>(.*?)<\/a>/g;
return preceeder + "<a href='/tags/" + tagText.toLowerCase() +
"' class='tag'>#" + tagText + "</a>" 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) { textFormatter.mentionify = function mentionify(text, mentions) {
......
...@@ -238,6 +238,13 @@ describe("app.helpers.textFormatter", function(){ ...@@ -238,6 +238,13 @@ describe("app.helpers.textFormatter", function(){
expect(formattedText).toContain("/tags/parties") 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);
})
}) })
}) })
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter