Merge pull request #5746 from svbergerem/markdown-linkify-www
Add missing http:// to urls
This commit is contained in:
commit
4a06c8c6bd
2 changed files with 6 additions and 0 deletions
|
|
@ -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";
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
Loading…
Reference in a new issue