summaryrefslogtreecommitdiff
path: root/bin/wiki/ImportarDesdeURL/node_modules/url-regex/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'bin/wiki/ImportarDesdeURL/node_modules/url-regex/index.js')
-rw-r--r--bin/wiki/ImportarDesdeURL/node_modules/url-regex/index.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/bin/wiki/ImportarDesdeURL/node_modules/url-regex/index.js b/bin/wiki/ImportarDesdeURL/node_modules/url-regex/index.js
new file mode 100644
index 00000000..a77d2632
--- /dev/null
+++ b/bin/wiki/ImportarDesdeURL/node_modules/url-regex/index.js
@@ -0,0 +1,22 @@
+'use strict';
+const ipRegex = require('ip-regex');
+const tlds = require('tlds');
+
+module.exports = options => {
+ options = {
+ strict: true,
+ ...options
+ };
+
+ const protocol = `(?:(?:[a-z]+:)?//)${options.strict ? '' : '?'}`;
+ const auth = '(?:\\S+(?::\\S*)?@)?';
+ const ip = ipRegex.v4().source;
+ const host = '(?:(?:[a-z\\u00a1-\\uffff0-9][-_]*)*[a-z\\u00a1-\\uffff0-9]+)';
+ const domain = '(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*';
+ const tld = `(?:\\.${options.strict ? '(?:[a-z\\u00a1-\\uffff]{2,})' : `(?:${tlds.sort((a, b) => b.length - a.length).join('|')})`})\\.?`;
+ const port = '(?::\\d{2,5})?';
+ const path = '(?:[/?#][^\\s"]*)?';
+ const regex = `(?:${protocol}|www\\.)${auth}(?:localhost|${ip}|${host}${domain}${tld})${port}${path}`;
+
+ return options.exact ? new RegExp(`(?:^${regex}$)`, 'i') : new RegExp(regex, 'ig');
+};