Skip to content
Extraits de code Groupes Projets
Valider 9c9562d0 rédigé par Maxwell Salzberg's avatar Maxwell Salzberg
Parcourir les fichiers

fix http urls with 3 slashes

parent 39d68804
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
// process links // process links
// regex copied from: https://code.google.com/p/pagedown/source/browse/Markdown.Converter.js#1198 (and slightly expanded) // regex copied from: https://code.google.com/p/pagedown/source/browse/Markdown.Converter.js#1198 (and slightly expanded)
var linkRegex = /(\[.*\]:\s)?(<|\()((https?|ftp):[^'">\s]+)(>|\))/gi; var linkRegex = /(\[.*\]:\s)?(<|\()((https?|ftp):\/\/[^\/'">\s][^'">\s]+)(>|\))/gi;
text = text.replace(linkRegex, function() { text = text.replace(linkRegex, function() {
var unicodeUrl = arguments[3]; var unicodeUrl = arguments[3];
var addr = parse_url(unicodeUrl); var addr = parse_url(unicodeUrl);
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
( (addr.scheme.toLowerCase()=="mailto") ? ':' : '://')) + ( (addr.scheme.toLowerCase()=="mailto") ? ':' : '://')) +
(!addr.user ? '' : addr.user + (!addr.user ? '' : addr.user +
(!addr.pass ? '' : ':'+addr.pass) + '@') + (!addr.pass ? '' : ':'+addr.pass) + '@') +
punycode.toASCII(addr.host) + punycode.toASCII(addr.host) +
(!addr.port ? '' : ':' + addr.port) + (!addr.port ? '' : ':' + addr.port) +
(!addr.path ? '' : addr.path) + (!addr.path ? '' : addr.path) +
(!addr.query ? '' : '?' + addr.query) + (!addr.query ? '' : '?' + addr.query) +
......
...@@ -69,5 +69,12 @@ describe("app.views.Post", function(){ ...@@ -69,5 +69,12 @@ describe("app.views.Post", function(){
expect($(view.el).html()).toContain(specialLink); expect($(view.el).html()).toContain(specialLink);
expect($(view.el).html()).toContain(normalLink); expect($(view.el).html()).toContain(normalLink);
}); });
it("works when three slashes are present in the url", function(){
var badURL = "http:///scholar.google.com/citations?view_op=top_venues"
this.statusMessage.set({text : badURL});
var view = new app.views.StreamPost({model: this.statusMessage}).render();
})
}); });
}); });
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