Merge pull request #5746 from svbergerem/markdown-linkify-www

Add missing http:// to urls
This commit is contained in:
Jonne Haß 2015-03-09 12:16:46 +01:00
commit 4a06c8c6bd
2 changed files with 6 additions and 0 deletions

View file

@ -42,6 +42,7 @@
});
md.use(inlinePlugin, 'link_new_window_and_punycode', 'link_open', function (tokens, idx) {
tokens[idx].href = tokens[idx].href.replace(/^www\./, "http://www.");
tokens[idx].href = punycodeURL(tokens[idx].href);
tokens[idx].target = "_blank";
});

View file

@ -116,6 +116,11 @@ describe("app.helpers.textFormatter", function(){
expect(this.formatter('<http://google.com>')).toContain('_blank');
});
it("adds a missing http://", function() {
expect(this.formatter('[test](www.google.com)')).toContain('href="http://www.google.com"');
expect(this.formatter('[test](http://www.google.com)')).toContain('href="http://www.google.com"');
});
it("respects code blocks", function() {
var content = '`<unknown tag>`';
var wrapper = $('<div>').html(this.formatter(content));