diff options
Diffstat (limited to 'dist/index.js')
-rw-r--r-- | dist/index.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 0000000..d3a9509 --- /dev/null +++ b/dist/index.js @@ -0,0 +1,31 @@ +'use strict'; + +var visit = require('unist-util-visit'); + +var schemes = require('./schemes.js'); + +function plugin() { + return transformer; + + function transformer(tree) { + visit(tree, 'link', function (link) { + if (link.url) { + if (link.url[0] === '/') { + // Local link + return; + } + + if (schemes.some(function (scheme) { + return link.url.startsWith(scheme + ':'); + })) { + // Valide scheme + return; + } + + link.url = '/' + link.url; + } + }); + } +} + +module.exports = plugin;
\ No newline at end of file |