Skip to content
Extraits de code Groupes Projets
Valider a1cf2792 rédigé par danielgrippi's avatar danielgrippi
Parcourir les fichiers

support twitter hashbangs in urls for url parsing [ci skip]

parent 5a9b1756
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -42,8 +42,8 @@ app.views.Content = app.views.StreamObject.extend({ ...@@ -42,8 +42,8 @@ app.views.Content = app.views.StreamObject.extend({
} }
function urlify(text) { function urlify(text) {
var urlRegex = /(=\s?'|=\s?")?[-a-zA-Z0-9@:%_\+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?/gi var urlRegex = /(=\s?'|=\s?")?[-a-zA-Z0-9@:%_\+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~#?(#!)&//=]*)?/gi
return text.replace(urlRegex, function(url, preceeder) { return text.replace(urlRegex, function(url, preceeder, bang) {
if(preceeder) return url if(preceeder) return url
var protocol = (url.search(/:\/\//) == -1 ? "http://" : "") var protocol = (url.search(/:\/\//) == -1 ? "http://" : "")
return "<a href='" + protocol + url + "' target=_blank>" + url + "</a>" return "<a href='" + protocol + url + "' target=_blank>" + url + "</a>"
......
...@@ -142,6 +142,14 @@ describe("app.views.Post", function(){ ...@@ -142,6 +142,14 @@ describe("app.views.Post", function(){
}) })
}) })
it("works with urls that use #! syntax (i'm looking at you, twitter)')", function(){
link = "http://twitter.com/#!/hashbangs?gross=true"
this.statusMessage.set({text : link})
var view = new app.views.Post({model : this.statusMessage}).render();
expect(view.$("a[href='" + link + "']").text()).toContain(link)
})
it("doesn't create link tags for links that are already in <a/> or <img/> tags", function(){ it("doesn't create link tags for links that are already in <a/> or <img/> tags", function(){
link = "http://google.com" link = "http://google.com"
......
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