Skip to content

Commit

Permalink
feat: don't linkify a link without http/https protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanyf committed Dec 6, 2017
1 parent 2c4bd67 commit 4ec92cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ var md = new MarkdownIt({
}
});

// don't linkify a domain without http/https protocol
md.linkify.set({ fuzzyLink: false });

// Link attributes plugin for markdown-it markdown parser.
md.use(require('./plugins/link-attributes'), {
target: '_blank',
Expand Down
11 changes: 8 additions & 3 deletions test/turpan.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var test = require('tape');
var md = require('../lib');

test('markdown test', function (t) {
t.plan(20);
t.plan(21);

t.equal(
md.render('`x = 2`'),
Expand All @@ -22,8 +22,13 @@ test('markdown test', function (t) {
);

t.equal(
md.render('www.yahoo.com'),
'<p><a href="http://www.yahoo.com" target="_blank" rel="noopener">www.yahoo.com</a></p>\n'
md.render('http://www.yahoo.com'),
'<p><a href="http://www.yahoo.com" target="_blank" rel="noopener">http://www.yahoo.com</a></p>\n'
);

t.equal(
md.render('a.md'),
'<p>a.md</p>\n'
);

t.equal(
Expand Down

0 comments on commit 4ec92cd

Please sign in to comment.