aboutsummaryrefslogtreecommitdiff
path: root/dist
diff options
context:
space:
mode:
authorache <ache@ache.one>2019-03-03 02:13:07 +0100
committerache <ache@ache.one>2019-03-03 02:14:59 +0100
commit6f054ca562d847b49544d2cb6e24fc91abede082 (patch)
tree4a3db33251fc7c789cb77bb9b7544cdd60c851c1 /dist
Init commit
Diffstat (limited to 'dist')
-rw-r--r--dist/index.js31
-rw-r--r--dist/schemes.js3
2 files changed, 34 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
diff --git a/dist/schemes.js b/dist/schemes.js
new file mode 100644
index 0000000..717eca8
--- /dev/null
+++ b/dist/schemes.js
@@ -0,0 +1,3 @@
+'use strict';
+
+module.exports = ['aaa', 'aaas', 'about', 'acap', 'acct', 'cap', 'cid', 'coap', 'coap+tcp', 'coap+ws', 'coaps', 'coaps+tcp', 'coaps+ws', 'crid', 'data', 'dav', 'dict', 'dns', 'example', 'file', 'ftp', 'geo', 'go', 'gopher', 'h323', 'http', 'https', 'iax', 'icap', 'im', 'imap', 'info', 'ipp', 'ipps', 'iris', 'iris.beep', 'iris.lwz', 'iris.xpc', 'iris.xpcs', 'jabber', 'ldap', 'leaptofrogans', 'mailto', 'mid', 'msrp', 'msrps', 'mtqp', 'mupdate', 'news', 'nfs', 'ni', 'nih', 'nntp', 'opaquelocktoken', 'pkcs11', 'pop', 'pres', 'reload', 'rtsp', 'rtsps', 'rtspu', 'service', 'session', 'shttp', 'sieve', 'sip', 'sips', 'sms', 'snmp', 'soap.beep', 'soap.beeps', 'stun', 'stuns', 'tag', 'tel', 'telnet', 'tftp', 'thismessage', 'tip', 'tn3270', 'turn', 'turns', 'tv', 'urn', 'vemmi', 'vnc', 'ws', 'wss', 'xcon', 'xcon-userid', 'xmlrpc.beep', 'xmlrpc.beeps', 'xmpp', 'z39.50r', 'z39.50s']; \ No newline at end of file