@mavogel/awscdk-rootmail 0.1.52 → 0.1.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +10 -10
- package/lib/rootmail.js +1 -1
- package/lib/ses-receive.js +1 -1
- package/node_modules/@aws-sdk/client-cloudwatch-logs/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-cloudwatch-logs/package.json +1 -1
- package/node_modules/@aws-sdk/client-route-53/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-route-53/package.json +1 -1
- package/node_modules/@aws-sdk/client-s3/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-s3/package.json +2 -2
- package/node_modules/@aws-sdk/client-ses/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-ses/package.json +1 -1
- package/node_modules/@aws-sdk/client-ssm/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-ssm/package.json +1 -1
- package/node_modules/linkify-it/README.md +49 -86
- package/node_modules/linkify-it/build/index.cjs.js +636 -825
- package/node_modules/linkify-it/build/index.cjs.js.map +1 -0
- package/node_modules/linkify-it/build/index.d.ts +236 -0
- package/node_modules/linkify-it/build/index.mjs +538 -0
- package/node_modules/linkify-it/build/index.mjs.map +1 -0
- package/node_modules/linkify-it/package.json +23 -20
- package/node_modules/mailparser/CHANGELOG.md +7 -0
- package/node_modules/mailparser/dist/cjs/mail-parser.js +34 -14
- package/node_modules/mailparser/dist/esm/mail-parser.js +34 -14
- package/node_modules/mailparser/package.json +2 -2
- package/node_modules/uc.micro/README.md +18 -1
- package/node_modules/uc.micro/build/index.cjs.js +13 -18
- package/node_modules/uc.micro/build/index.d.ts +6 -0
- package/node_modules/uc.micro/build/index.mjs +8 -0
- package/node_modules/uc.micro/package.json +12 -17
- package/package.json +11 -11
- package/node_modules/linkify-it/index.mjs +0 -646
- package/node_modules/linkify-it/lib/re.mjs +0 -193
- package/node_modules/uc.micro/categories/Cc/regex.mjs +0 -1
- package/node_modules/uc.micro/categories/Cf/regex.mjs +0 -1
- package/node_modules/uc.micro/categories/P/regex.mjs +0 -1
- package/node_modules/uc.micro/categories/S/regex.mjs +0 -1
- package/node_modules/uc.micro/categories/Z/regex.mjs +0 -1
- package/node_modules/uc.micro/index.mjs +0 -8
- package/node_modules/uc.micro/properties/Any/regex.mjs +0 -1
|
@@ -1,840 +1,651 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
re.src_Z = uc_micro.Z.source;
|
|
12
|
-
re.src_P = uc_micro.P.source;
|
|
13
|
-
|
|
14
|
-
// \p{\Z\P\Cc\CF} (white spaces + control + format + punctuation)
|
|
15
|
-
re.src_ZPCc = [re.src_Z, re.src_P, re.src_Cc].join('|');
|
|
16
|
-
|
|
17
|
-
// \p{\Z\Cc} (white spaces + control)
|
|
18
|
-
re.src_ZCc = [re.src_Z, re.src_Cc].join('|');
|
|
19
|
-
|
|
20
|
-
// Experimental. List of chars, completely prohibited in links
|
|
21
|
-
// because can separate it from other part of text
|
|
22
|
-
const text_separators = '[><\uff5c]';
|
|
23
|
-
|
|
24
|
-
// All possible word characters (everything without punctuation, spaces & controls)
|
|
25
|
-
// Defined via punctuation & spaces to save space
|
|
26
|
-
// Should be something like \p{\L\N\S\M} (\w but without `_`)
|
|
27
|
-
re.src_pseudo_letter = `(?:(?!${text_separators}|${re.src_ZPCc})${re.src_Any})`;
|
|
28
|
-
// The same as abothe but without [0-9]
|
|
29
|
-
// var src_pseudo_letter_non_d = '(?:(?![0-9]|' + src_ZPCc + ')' + src_Any + ')';
|
|
30
|
-
|
|
31
|
-
re.src_ip4 =
|
|
32
|
-
|
|
33
|
-
'(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)';
|
|
34
|
-
|
|
35
|
-
// Prohibit any of "@/[]()" in user/pass to avoid wrong domain fetch.
|
|
36
|
-
// Length is capped to exclude possible rescans till the end and avoid O(n^2)
|
|
37
|
-
// DoS. No standard limit, just take something reasonable.
|
|
38
|
-
re.src_auth = `(?:(?:(?!${re.src_ZCc}|[@/\\[\\]()]).){1,50}@)?`;
|
|
39
|
-
|
|
40
|
-
re.src_port =
|
|
41
|
-
|
|
42
|
-
'(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?';
|
|
43
|
-
|
|
44
|
-
re.src_host_terminator =
|
|
45
|
-
|
|
46
|
-
`(?=$|${text_separators}|${re.src_ZPCc})` +
|
|
47
|
-
`(?!${opts['---'] ? '-(?!--)|' : '-|'}_|:\\d|\\.-|\\.(?!$|${re.src_ZPCc}))`;
|
|
48
|
-
|
|
49
|
-
re.src_path =
|
|
50
|
-
|
|
51
|
-
'(?:' +
|
|
52
|
-
'[/?#]' +
|
|
53
|
-
'(?:' +
|
|
54
|
-
`(?!${re.src_ZCc}|${text_separators}|[()[\\]{}.,"'?!\\-;]).|` +
|
|
55
|
-
`\\[(?:(?!${re.src_ZCc}|\\]).)*\\]|` +
|
|
56
|
-
`\\((?:(?!${re.src_ZCc}|[)]).)*\\)|` +
|
|
57
|
-
`\\{(?:(?!${re.src_ZCc}|[}]).)*\\}|` +
|
|
58
|
-
`\\"(?:(?!${re.src_ZCc}|["]).)+\\"|` +
|
|
59
|
-
`\\'(?:(?!${re.src_ZCc}|[']).)+\\'|` +
|
|
60
|
-
|
|
61
|
-
// allow `I'm_king` if no pair found
|
|
62
|
-
`\\'(?=${re.src_pseudo_letter}|[-])|` +
|
|
63
|
-
|
|
64
|
-
// google has many dots in "google search" links (#66, #81).
|
|
65
|
-
// github has ... in commit range links,
|
|
66
|
-
// Restrict to
|
|
67
|
-
// - english
|
|
68
|
-
// - percent-encoded
|
|
69
|
-
// - parts of file path
|
|
70
|
-
// - params separator
|
|
71
|
-
// until more examples found.
|
|
72
|
-
'\\.{2,}[a-zA-Z0-9%/&]|' +
|
|
73
|
-
|
|
74
|
-
`\\.(?!${re.src_ZCc}|[.]|$)|` +
|
|
75
|
-
(opts['---']
|
|
76
|
-
? '\\-(?!--(?:[^-]|$))(?:-*)|' // `---` => long dash, terminate
|
|
77
|
-
: '\\-+|'
|
|
78
|
-
) +
|
|
79
|
-
// allow `,,,` in paths
|
|
80
|
-
`,(?!${re.src_ZCc}|$)|` +
|
|
81
|
-
|
|
82
|
-
// allow `;` if not followed by space-like char
|
|
83
|
-
`;(?!${re.src_ZCc}|$)|` +
|
|
84
|
-
|
|
85
|
-
// allow `!!!` in paths, but not at the end
|
|
86
|
-
`\\!+(?!${re.src_ZCc}|[!]|$)|` +
|
|
87
|
-
|
|
88
|
-
`\\?(?!${re.src_ZCc}|[?]|$)` +
|
|
89
|
-
')+' +
|
|
90
|
-
'|\\/' +
|
|
91
|
-
')?';
|
|
92
|
-
|
|
93
|
-
// Allow anything in markdown spec, forbid quote (") at the first position
|
|
94
|
-
// because emails enclosed in quotes are far more common
|
|
95
|
-
// Max name length capped to 64 chars (RFC 5321). This also prevents O(n^2)
|
|
96
|
-
// rescans to the end on inputs like `mailto:mailto:...`
|
|
97
|
-
re.src_email_name =
|
|
98
|
-
|
|
99
|
-
'[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]{0,63}';
|
|
100
|
-
|
|
101
|
-
re.src_xn =
|
|
102
|
-
|
|
103
|
-
'xn--[a-z0-9\\-]{1,59}';
|
|
104
|
-
|
|
105
|
-
// More to read about domain names
|
|
106
|
-
// http://serverfault.com/questions/638260/
|
|
107
|
-
|
|
108
|
-
re.src_domain_root =
|
|
109
|
-
|
|
110
|
-
// Allow letters & digits (http://test1)
|
|
111
|
-
'(?:' +
|
|
112
|
-
re.src_xn +
|
|
113
|
-
'|' +
|
|
114
|
-
`${re.src_pseudo_letter}{1,63}` +
|
|
115
|
-
')';
|
|
116
|
-
|
|
117
|
-
re.src_domain =
|
|
118
|
-
|
|
119
|
-
'(?:' +
|
|
120
|
-
re.src_xn +
|
|
121
|
-
'|' +
|
|
122
|
-
`(?:${re.src_pseudo_letter})` +
|
|
123
|
-
'|' +
|
|
124
|
-
`(?:${re.src_pseudo_letter}(?:-|${re.src_pseudo_letter}){0,61}${re.src_pseudo_letter})` +
|
|
125
|
-
')';
|
|
126
|
-
|
|
127
|
-
re.src_host =
|
|
128
|
-
|
|
129
|
-
'(?:' +
|
|
130
|
-
// Don't need IP check, because digits are already allowed in normal domain names
|
|
131
|
-
// src_ip4 +
|
|
132
|
-
// '|' +
|
|
133
|
-
`(?:(?:(?:${re.src_domain})\\.)*${re.src_domain})`/* _root */ +
|
|
134
|
-
')';
|
|
135
|
-
|
|
136
|
-
re.tpl_host_fuzzy =
|
|
137
|
-
|
|
138
|
-
'(?:' +
|
|
139
|
-
re.src_ip4 +
|
|
140
|
-
'|' +
|
|
141
|
-
`(?:(?:(?:${re.src_domain})\\.)+(?:%TLDS%))` +
|
|
142
|
-
')';
|
|
143
|
-
|
|
144
|
-
re.tpl_host_no_ip_fuzzy =
|
|
145
|
-
|
|
146
|
-
`(?:(?:(?:${re.src_domain})\\.)+(?:%TLDS%))`;
|
|
147
|
-
|
|
148
|
-
re.src_host_strict =
|
|
149
|
-
|
|
150
|
-
re.src_host + re.src_host_terminator;
|
|
151
|
-
|
|
152
|
-
re.tpl_host_fuzzy_strict =
|
|
153
|
-
|
|
154
|
-
re.tpl_host_fuzzy + re.src_host_terminator;
|
|
155
|
-
|
|
156
|
-
re.src_host_port_strict =
|
|
157
|
-
|
|
158
|
-
re.src_host + re.src_port + re.src_host_terminator;
|
|
159
|
-
|
|
160
|
-
re.tpl_host_port_fuzzy_strict =
|
|
161
|
-
|
|
162
|
-
re.tpl_host_fuzzy + re.src_port + re.src_host_terminator;
|
|
163
|
-
|
|
164
|
-
re.tpl_host_port_no_ip_fuzzy_strict =
|
|
165
|
-
|
|
166
|
-
re.tpl_host_no_ip_fuzzy + re.src_port + re.src_host_terminator;
|
|
167
|
-
|
|
168
|
-
//
|
|
169
|
-
// Main rules
|
|
170
|
-
//
|
|
171
|
-
|
|
172
|
-
// Rude test fuzzy links by host, for quick deny
|
|
173
|
-
re.tpl_host_fuzzy_test =
|
|
174
|
-
|
|
175
|
-
`localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:${re.src_ZPCc}|>|$))`;
|
|
176
|
-
|
|
177
|
-
re.tpl_email_fuzzy =
|
|
178
|
-
|
|
179
|
-
`(^|${text_separators}|"|\\(|${re.src_ZCc})` +
|
|
180
|
-
`(${re.src_email_name}@${re.tpl_host_fuzzy_strict})`;
|
|
181
|
-
|
|
182
|
-
re.tpl_link_fuzzy =
|
|
183
|
-
// Fuzzy link can't be prepended with .:/\- and non punctuation.
|
|
184
|
-
// but can start with > (markdown blockquote)
|
|
185
|
-
`(^|(?![.:/\\-_@])(?:[$+<=>^\`|\uff5c]|${re.src_ZPCc}))` +
|
|
186
|
-
`((?![$+<=>^\`|\uff5c])${re.tpl_host_port_fuzzy_strict}${re.src_path})`;
|
|
187
|
-
|
|
188
|
-
re.tpl_link_no_ip_fuzzy =
|
|
189
|
-
// Fuzzy link can't be prepended with .:/\- and non punctuation.
|
|
190
|
-
// but can start with > (markdown blockquote)
|
|
191
|
-
`(^|(?![.:/\\-_@])(?:[$+<=>^\`|\uff5c]|${re.src_ZPCc}))` +
|
|
192
|
-
`((?![$+<=>^\`|\uff5c])${re.tpl_host_port_no_ip_fuzzy_strict}${re.src_path})`;
|
|
193
|
-
|
|
194
|
-
return re
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let uc_micro = require("uc.micro");
|
|
3
|
+
//#region \0@oxc-project+runtime@0.138.0/helpers/esm/typeof.js
|
|
4
|
+
function _typeof(o) {
|
|
5
|
+
"@babel/helpers - typeof";
|
|
6
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
7
|
+
return typeof o;
|
|
8
|
+
} : function(o) {
|
|
9
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
10
|
+
}, _typeof(o);
|
|
195
11
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
if (!source) { return }
|
|
208
|
-
|
|
209
|
-
Object.keys(source).forEach(function (key) {
|
|
210
|
-
obj[key] = source[key];
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
return obj
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region \0@oxc-project+runtime@0.138.0/helpers/esm/toPrimitive.js
|
|
14
|
+
function toPrimitive(t, r) {
|
|
15
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
16
|
+
var e = t[Symbol.toPrimitive];
|
|
17
|
+
if (void 0 !== e) {
|
|
18
|
+
var i = e.call(t, r || "default");
|
|
19
|
+
if ("object" != _typeof(i)) return i;
|
|
20
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
21
|
+
}
|
|
22
|
+
return ("string" === r ? String : Number)(t);
|
|
215
23
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
function
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
function isFunction (obj) { return _class(obj) === '[object Function]' }
|
|
222
|
-
|
|
223
|
-
function escapeRE (str) { return str.replace(/[.?*+^$[\]\\(){}|-]/g, '\\$&') }
|
|
224
|
-
|
|
225
|
-
//
|
|
226
|
-
|
|
227
|
-
const defaultOptions = {
|
|
228
|
-
fuzzyLink: true,
|
|
229
|
-
fuzzyEmail: true,
|
|
230
|
-
fuzzyIP: false
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
function isOptionsObj (obj) {
|
|
234
|
-
return Object.keys(obj || {}).reduce(function (acc, k) {
|
|
235
|
-
/* eslint-disable-next-line no-prototype-builtins */
|
|
236
|
-
return acc || defaultOptions.hasOwnProperty(k)
|
|
237
|
-
}, false)
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region \0@oxc-project+runtime@0.138.0/helpers/esm/toPropertyKey.js
|
|
26
|
+
function toPropertyKey(t) {
|
|
27
|
+
var i = toPrimitive(t, "string");
|
|
28
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
238
29
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
`^\\/\\/${self.re.src_auth}${self.re.src_host_port_strict}${self.re.src_path}`, 'i'
|
|
249
|
-
);
|
|
250
|
-
}
|
|
251
|
-
if (self.re.http.test(tail)) {
|
|
252
|
-
return tail.match(self.re.http)[0].length
|
|
253
|
-
}
|
|
254
|
-
return 0
|
|
255
|
-
}
|
|
256
|
-
},
|
|
257
|
-
'https:': 'http:',
|
|
258
|
-
'ftp:': 'http:',
|
|
259
|
-
'//': {
|
|
260
|
-
validate: function (text, pos, self) {
|
|
261
|
-
const tail = text.slice(pos);
|
|
262
|
-
|
|
263
|
-
if (!self.re.no_http) {
|
|
264
|
-
// compile lazily, because "host"-containing variables can change on tlds update.
|
|
265
|
-
self.re.no_http = new RegExp(
|
|
266
|
-
'^' +
|
|
267
|
-
self.re.src_auth +
|
|
268
|
-
// Don't allow single-level domains, because of false positives like '//test'
|
|
269
|
-
// with code comments
|
|
270
|
-
`(?:localhost|(?:(?:${self.re.src_domain})\\.)+${self.re.src_domain_root})` +
|
|
271
|
-
self.re.src_port +
|
|
272
|
-
self.re.src_host_terminator +
|
|
273
|
-
self.re.src_path,
|
|
274
|
-
|
|
275
|
-
'i'
|
|
276
|
-
);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
if (self.re.no_http.test(tail)) {
|
|
280
|
-
// should not be `://` & `///`, that protects from errors in protocol name
|
|
281
|
-
if (pos >= 3 && text[pos - 3] === ':') { return 0 }
|
|
282
|
-
if (pos >= 3 && text[pos - 3] === '/') { return 0 }
|
|
283
|
-
return tail.match(self.re.no_http)[0].length
|
|
284
|
-
}
|
|
285
|
-
return 0
|
|
286
|
-
}
|
|
287
|
-
},
|
|
288
|
-
'mailto:': {
|
|
289
|
-
validate: function (text, pos, self) {
|
|
290
|
-
const tail = text.slice(pos);
|
|
291
|
-
|
|
292
|
-
if (!self.re.mailto) {
|
|
293
|
-
self.re.mailto = new RegExp(
|
|
294
|
-
`^${self.re.src_email_name}@${self.re.src_host_strict}`, 'i'
|
|
295
|
-
);
|
|
296
|
-
}
|
|
297
|
-
if (self.re.mailto.test(tail)) {
|
|
298
|
-
return tail.match(self.re.mailto)[0].length
|
|
299
|
-
}
|
|
300
|
-
return 0
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
// RE pattern for 2-character tlds (autogenerated by ./support/tlds_2char_gen.js)
|
|
306
|
-
const tlds_2ch_src_re = 'a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]';
|
|
307
|
-
|
|
308
|
-
// DON'T try to make PRs with changes. Extend TLDs with LinkifyIt.tlds() instead
|
|
309
|
-
const tlds_default = 'biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф'.split('|');
|
|
310
|
-
|
|
311
|
-
function createValidator (re) {
|
|
312
|
-
return function (text, pos) {
|
|
313
|
-
const tail = text.slice(pos);
|
|
314
|
-
|
|
315
|
-
if (re.test(tail)) {
|
|
316
|
-
return tail.match(re)[0].length
|
|
317
|
-
}
|
|
318
|
-
return 0
|
|
319
|
-
}
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region \0@oxc-project+runtime@0.138.0/helpers/esm/defineProperty.js
|
|
32
|
+
function _defineProperty(e, r, t) {
|
|
33
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
34
|
+
value: t,
|
|
35
|
+
enumerable: !0,
|
|
36
|
+
configurable: !0,
|
|
37
|
+
writable: !0
|
|
38
|
+
}) : e[r] = t, e;
|
|
320
39
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region \0@oxc-project+runtime@0.138.0/helpers/esm/objectSpread2.js
|
|
42
|
+
function ownKeys(e, r) {
|
|
43
|
+
var t = Object.keys(e);
|
|
44
|
+
if (Object.getOwnPropertySymbols) {
|
|
45
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
46
|
+
r && (o = o.filter(function(r) {
|
|
47
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
48
|
+
})), t.push.apply(t, o);
|
|
49
|
+
}
|
|
50
|
+
return t;
|
|
326
51
|
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
self.onCompile();
|
|
338
|
-
|
|
339
|
-
if (!self.__tlds_replaced__) {
|
|
340
|
-
tlds.push(tlds_2ch_src_re);
|
|
341
|
-
}
|
|
342
|
-
tlds.push(re.src_xn);
|
|
343
|
-
|
|
344
|
-
re.src_tlds = tlds.join('|');
|
|
345
|
-
|
|
346
|
-
function untpl (tpl) { return tpl.replace('%TLDS%', re.src_tlds) }
|
|
347
|
-
|
|
348
|
-
re.email_fuzzy = RegExp(untpl(re.tpl_email_fuzzy), 'i');
|
|
349
|
-
re.email_fuzzy_global = RegExp(untpl(re.tpl_email_fuzzy), 'ig');
|
|
350
|
-
re.link_fuzzy = RegExp(untpl(re.tpl_link_fuzzy), 'i');
|
|
351
|
-
re.link_fuzzy_global = RegExp(untpl(re.tpl_link_fuzzy), 'ig');
|
|
352
|
-
re.link_no_ip_fuzzy = RegExp(untpl(re.tpl_link_no_ip_fuzzy), 'i');
|
|
353
|
-
re.link_no_ip_fuzzy_global = RegExp(untpl(re.tpl_link_no_ip_fuzzy), 'ig');
|
|
354
|
-
re.host_fuzzy_test = RegExp(untpl(re.tpl_host_fuzzy_test), 'i');
|
|
355
|
-
|
|
356
|
-
//
|
|
357
|
-
// Compile each schema
|
|
358
|
-
//
|
|
359
|
-
|
|
360
|
-
const aliases = [];
|
|
361
|
-
|
|
362
|
-
self.__compiled__ = {}; // Reset compiled data
|
|
363
|
-
|
|
364
|
-
function schemaError (name, val) {
|
|
365
|
-
throw new Error(`(LinkifyIt) Invalid schema "${name}": ${val}`)
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
Object.keys(self.__schemas__).forEach(function (name) {
|
|
369
|
-
const val = self.__schemas__[name];
|
|
370
|
-
|
|
371
|
-
// skip disabled methods
|
|
372
|
-
if (val === null) { return }
|
|
373
|
-
|
|
374
|
-
const compiled = { validate: null, link: null };
|
|
375
|
-
|
|
376
|
-
self.__compiled__[name] = compiled;
|
|
377
|
-
|
|
378
|
-
if (isObject(val)) {
|
|
379
|
-
if (isRegExp(val.validate)) {
|
|
380
|
-
compiled.validate = createValidator(val.validate);
|
|
381
|
-
} else if (isFunction(val.validate)) {
|
|
382
|
-
compiled.validate = val.validate;
|
|
383
|
-
} else {
|
|
384
|
-
schemaError(name, val);
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
if (isFunction(val.normalize)) {
|
|
388
|
-
compiled.normalize = val.normalize;
|
|
389
|
-
} else if (!val.normalize) {
|
|
390
|
-
compiled.normalize = createNormalizer();
|
|
391
|
-
} else {
|
|
392
|
-
schemaError(name, val);
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
return
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
if (isString(val)) {
|
|
399
|
-
aliases.push(name);
|
|
400
|
-
return
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
schemaError(name, val);
|
|
404
|
-
});
|
|
405
|
-
|
|
406
|
-
//
|
|
407
|
-
// Compile postponed aliases
|
|
408
|
-
//
|
|
409
|
-
|
|
410
|
-
aliases.forEach(function (alias) {
|
|
411
|
-
if (!self.__compiled__[self.__schemas__[alias]]) {
|
|
412
|
-
// Silently fail on missed schemas to avoid errons on disable.
|
|
413
|
-
// schemaError(alias, self.__schemas__[alias]);
|
|
414
|
-
return
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
self.__compiled__[alias].validate =
|
|
418
|
-
self.__compiled__[self.__schemas__[alias]].validate;
|
|
419
|
-
self.__compiled__[alias].normalize =
|
|
420
|
-
self.__compiled__[self.__schemas__[alias]].normalize;
|
|
421
|
-
});
|
|
422
|
-
|
|
423
|
-
//
|
|
424
|
-
// Fake record for guessed links
|
|
425
|
-
//
|
|
426
|
-
self.__compiled__[''] = { validate: null, normalize: createNormalizer() };
|
|
427
|
-
|
|
428
|
-
//
|
|
429
|
-
// Build schema condition
|
|
430
|
-
//
|
|
431
|
-
const slist = Object.keys(self.__compiled__)
|
|
432
|
-
.filter(function (name) {
|
|
433
|
-
// Filter disabled & fake schemas
|
|
434
|
-
return name.length > 0 && self.__compiled__[name]
|
|
435
|
-
})
|
|
436
|
-
.map(escapeRE)
|
|
437
|
-
.join('|');
|
|
438
|
-
// (?!_) cause 1.5x slowdown
|
|
439
|
-
self.re.schema_test = RegExp(`(^|(?!_)(?:[><\uff5c]|${re.src_ZPCc}))(${slist})`, 'i');
|
|
440
|
-
self.re.schema_search = RegExp(`(^|(?!_)(?:[><\uff5c]|${re.src_ZPCc}))(${slist})`, 'ig');
|
|
441
|
-
self.re.schema_at_start = RegExp(`^${self.re.schema_search.source}`, 'i');
|
|
442
|
-
|
|
443
|
-
self.re.pretest = RegExp(
|
|
444
|
-
`(${self.re.schema_test.source})|(${self.re.host_fuzzy_test.source})|@`,
|
|
445
|
-
'i'
|
|
446
|
-
);
|
|
52
|
+
function _objectSpread2(e) {
|
|
53
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
54
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
55
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
|
|
56
|
+
_defineProperty(e, r, t[r]);
|
|
57
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
|
|
58
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return e;
|
|
447
62
|
}
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/rebuilder.ts
|
|
65
|
+
var REBuilder = class {
|
|
66
|
+
constructor(opts = {}) {
|
|
67
|
+
_defineProperty(this, "src_Any", uc_micro.Any.source);
|
|
68
|
+
_defineProperty(this, "src_Cc", uc_micro.Cc.source);
|
|
69
|
+
_defineProperty(this, "src_Z", uc_micro.Z.source);
|
|
70
|
+
_defineProperty(this, "src_P", uc_micro.P.source);
|
|
71
|
+
_defineProperty(this, "src_ZPCc", [
|
|
72
|
+
this.src_Z,
|
|
73
|
+
this.src_P,
|
|
74
|
+
this.src_Cc
|
|
75
|
+
].join("|"));
|
|
76
|
+
_defineProperty(this, "src_ZCc", [this.src_Z, this.src_Cc].join("|"));
|
|
77
|
+
_defineProperty(this, "cache", {});
|
|
78
|
+
_defineProperty(this, "opts", {
|
|
79
|
+
maxLength: 1e4,
|
|
80
|
+
urlAuth: false,
|
|
81
|
+
schema_names: []
|
|
82
|
+
});
|
|
83
|
+
this.opts = _objectSpread2(_objectSpread2({}, this.opts), opts);
|
|
84
|
+
}
|
|
85
|
+
set(opts = {}) {
|
|
86
|
+
this.opts = _objectSpread2(_objectSpread2({}, this.opts), opts);
|
|
87
|
+
this.cache = {};
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
90
|
+
escapeRE(str) {
|
|
91
|
+
return str.replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&");
|
|
92
|
+
}
|
|
93
|
+
nestedPairRE(open, close, depth = 4) {
|
|
94
|
+
const openRE = this.escapeRE(open);
|
|
95
|
+
const closeRE = this.escapeRE(close);
|
|
96
|
+
const atom = `(?:(?!${this.src_ZCc}|${openRE}|${closeRE}).)`;
|
|
97
|
+
let pair = `${openRE}${atom}{0,1000}${closeRE}`;
|
|
98
|
+
for (let level = 2; level <= depth; level++) pair = `${openRE}(?:${atom}|${pair}){0,1000}${closeRE}`;
|
|
99
|
+
return pair;
|
|
100
|
+
}
|
|
101
|
+
get_text_separators() {
|
|
102
|
+
var _this$cache, _this$cache$text_sepa;
|
|
103
|
+
return (_this$cache$text_sepa = (_this$cache = this.cache).text_separators) !== null && _this$cache$text_sepa !== void 0 ? _this$cache$text_sepa : _this$cache.text_separators = /[><\uff5c]/;
|
|
104
|
+
}
|
|
105
|
+
get_pseudo_letter() {
|
|
106
|
+
var _this$cache2, _this$cache2$src_pseu;
|
|
107
|
+
return (_this$cache2$src_pseu = (_this$cache2 = this.cache).src_pseudo_letter) !== null && _this$cache2$src_pseu !== void 0 ? _this$cache2$src_pseu : _this$cache2.src_pseudo_letter = new RegExp(`(?:(?!${this.get_text_separators().source}|${this.src_ZPCc})${this.src_Any})`);
|
|
108
|
+
}
|
|
109
|
+
get_ipv4_addr() {
|
|
110
|
+
var _this$cache3, _this$cache3$src_ip;
|
|
111
|
+
return (_this$cache3$src_ip = (_this$cache3 = this.cache).src_ip4) !== null && _this$cache3$src_ip !== void 0 ? _this$cache3$src_ip : _this$cache3.src_ip4 = /* @__PURE__ */ new RegExp("(?:(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])[.]){3}(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])");
|
|
112
|
+
}
|
|
113
|
+
get_ipv6_addr() {
|
|
114
|
+
var _this$cache4, _this$cache4$src_ip6_;
|
|
115
|
+
const h16 = "[0-9A-Fa-f]{1,4}";
|
|
116
|
+
const ls32 = `(?:(?:${h16}:${h16})|${this.get_ipv4_addr().source})`;
|
|
117
|
+
return (_this$cache4$src_ip6_ = (_this$cache4 = this.cache).src_ip6_addr) !== null && _this$cache4$src_ip6_ !== void 0 ? _this$cache4$src_ip6_ : _this$cache4.src_ip6_addr = new RegExp(`(?:(?:${h16}:){6}${ls32}|::(?:${h16}:){5}${ls32}|(?:${h16})?::(?:${h16}:){4}${ls32}|(?:(?:${h16}:){0,1}${h16})?::(?:${h16}:){3}${ls32}|(?:(?:${h16}:){0,2}${h16})?::(?:${h16}:){2}${ls32}|(?:(?:${h16}:){0,3}${h16})?::${h16}:${ls32}|(?:(?:${h16}:){0,4}${h16})?::${ls32}|(?:(?:${h16}:){0,5}${h16})?::${h16}|(?:(?:${h16}:){0,6}${h16})?::)`);
|
|
118
|
+
}
|
|
119
|
+
get_ipv6_url_host() {
|
|
120
|
+
var _this$cache5, _this$cache5$src_ip6_;
|
|
121
|
+
return (_this$cache5$src_ip6_ = (_this$cache5 = this.cache).src_ip6_host) !== null && _this$cache5$src_ip6_ !== void 0 ? _this$cache5$src_ip6_ : _this$cache5.src_ip6_host = new RegExp(`\\[${this.get_ipv6_addr().source}\\]`);
|
|
122
|
+
}
|
|
123
|
+
get_ipv6_mail_host() {
|
|
124
|
+
var _this$cache6, _this$cache6$src_ipv;
|
|
125
|
+
return (_this$cache6$src_ipv = (_this$cache6 = this.cache).src_ipv6_mail_host) !== null && _this$cache6$src_ipv !== void 0 ? _this$cache6$src_ipv : _this$cache6.src_ipv6_mail_host = new RegExp(`\\[IPv6:${this.get_ipv6_addr().source}\\]`);
|
|
126
|
+
}
|
|
127
|
+
get_auth() {
|
|
128
|
+
var _this$cache7, _this$cache7$src_auth;
|
|
129
|
+
return (_this$cache7$src_auth = (_this$cache7 = this.cache).src_auth) !== null && _this$cache7$src_auth !== void 0 ? _this$cache7$src_auth : _this$cache7.src_auth = new RegExp(`(?:(?:(?!${this.src_ZCc}|[@/\\[\\]()]).){1,50}@)?`);
|
|
130
|
+
}
|
|
131
|
+
get_port() {
|
|
132
|
+
var _this$cache8, _this$cache8$src_port;
|
|
133
|
+
return (_this$cache8$src_port = (_this$cache8 = this.cache).src_port) !== null && _this$cache8$src_port !== void 0 ? _this$cache8$src_port : _this$cache8.src_port = /* @__PURE__ */ new RegExp("(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?");
|
|
134
|
+
}
|
|
135
|
+
get_host_terminator() {
|
|
136
|
+
var _this$cache9, _this$cache9$src_host;
|
|
137
|
+
return (_this$cache9$src_host = (_this$cache9 = this.cache).src_host_terminator) !== null && _this$cache9$src_host !== void 0 ? _this$cache9$src_host : _this$cache9.src_host_terminator = new RegExp(`(?=$|${this.get_text_separators().source}|${this.src_ZPCc})(?!${this.opts["---"] ? "-(?!--)|" : "-|"}_|:\\d|\\.-|\\.(?!$|${this.src_ZPCc}))`);
|
|
138
|
+
}
|
|
139
|
+
get_path_terminator() {
|
|
140
|
+
var _this$cache10, _this$cache10$src_pat;
|
|
141
|
+
return (_this$cache10$src_pat = (_this$cache10 = this.cache).src_path_terminator) !== null && _this$cache10$src_pat !== void 0 ? _this$cache10$src_pat : _this$cache10.src_path_terminator = new RegExp(`${this.src_ZPCc}|${this.get_text_separators().source}`);
|
|
142
|
+
}
|
|
143
|
+
get_path() {
|
|
144
|
+
var _this$cache11, _this$cache11$src_pat;
|
|
145
|
+
return (_this$cache11$src_pat = (_this$cache11 = this.cache).src_path) !== null && _this$cache11$src_pat !== void 0 ? _this$cache11$src_pat : _this$cache11.src_path = new RegExp(`(?:[/?#](?:${this.nestedPairRE("[", "]")}|${this.nestedPairRE("(", ")")}|${this.nestedPairRE("{", "}")}|\\"(?:(?!${this.src_ZCc}|["]).){1,100}\\"|\\'(?:(?!${this.src_ZCc}|[']).){1,100}\\'|\\'(?=${this.get_pseudo_letter().source}|[-])|\\.{2,20}[:]?[a-zA-Z0-9%/&]|\\.(?!${this.src_ZCc}|[.]|$)|` + (this.opts["---"] ? "\\-(?!--(?:[^-]|$))(?:-{0,19})|" : "\\-{1,20}|") + `,(?!${this.src_ZCc}|$)|;(?!${this.src_ZCc}|$)|\\!{1,20}(?!${this.src_ZCc}|[!]|$)|\\?(?!${this.src_ZCc}|[?]|$)|` + this.get_path_extra().source + `[\\\\/:%@#&=_~*]|(?!${this.get_path_terminator().source}).){1,${this.opts.maxLength}}|\\/)?`);
|
|
146
|
+
}
|
|
147
|
+
get_mail_name() {
|
|
148
|
+
var _this$cache12, _this$cache12$src_mai;
|
|
149
|
+
return (_this$cache12$src_mai = (_this$cache12 = this.cache).src_mail_name) !== null && _this$cache12$src_mai !== void 0 ? _this$cache12$src_mai : _this$cache12.src_mail_name = /* @__PURE__ */ new RegExp("[-!#$%&'*+/=?^_`{|}~a-zA-Z0-9](?:[-!#$%&'*+/=?^_`{|}~a-zA-Z0-9]|[.](?=[-!#$%&'*+/=?^_`{|}~a-zA-Z0-9])){0,63}");
|
|
150
|
+
}
|
|
151
|
+
get_xn() {
|
|
152
|
+
var _this$cache13, _this$cache13$src_xn;
|
|
153
|
+
return (_this$cache13$src_xn = (_this$cache13 = this.cache).src_xn) !== null && _this$cache13$src_xn !== void 0 ? _this$cache13$src_xn : _this$cache13.src_xn = /* @__PURE__ */ new RegExp("xn--[a-z0-9\\-]{1,59}");
|
|
154
|
+
}
|
|
155
|
+
get_tld() {
|
|
156
|
+
if (this.cache.tld) return this.cache.tld;
|
|
157
|
+
const tlds_src = [...new Set(this.opts.tlds || [])].sort().reverse().join("|");
|
|
158
|
+
this.cache.tld = new RegExp(`${tlds_src || "$#none#$"}|${this.get_xn().source}`);
|
|
159
|
+
return this.cache.tld;
|
|
160
|
+
}
|
|
161
|
+
get_domain_root() {
|
|
162
|
+
var _this$cache14, _this$cache14$src_dom;
|
|
163
|
+
return (_this$cache14$src_dom = (_this$cache14 = this.cache).src_domain_root) !== null && _this$cache14$src_dom !== void 0 ? _this$cache14$src_dom : _this$cache14.src_domain_root = new RegExp("(?:" + this.get_xn().source + `|${this.get_pseudo_letter().source}{1,63})`);
|
|
164
|
+
}
|
|
165
|
+
get_domain() {
|
|
166
|
+
var _this$cache15, _this$cache15$src_dom;
|
|
167
|
+
return (_this$cache15$src_dom = (_this$cache15 = this.cache).src_domain) !== null && _this$cache15$src_dom !== void 0 ? _this$cache15$src_dom : _this$cache15.src_domain = new RegExp("(?:" + this.get_xn().source + `|(?:${this.get_pseudo_letter().source})|(?:${this.get_pseudo_letter().source}(?:-|${this.get_pseudo_letter().source}){0,61}${this.get_pseudo_letter().source}))`);
|
|
168
|
+
}
|
|
169
|
+
get_url_host_port() {
|
|
170
|
+
var _this$cache16, _this$cache16$url_hos;
|
|
171
|
+
return (_this$cache16$url_hos = (_this$cache16 = this.cache).url_host_port) !== null && _this$cache16$url_hos !== void 0 ? _this$cache16$url_hos : _this$cache16.url_host_port = new RegExp("(?:" + this.get_ipv6_url_host().source + `|(?:(?:(?:${this.get_domain().source})\\.){0,10}${this.get_domain().source}))` + this.get_port().source + this.get_host_terminator().source);
|
|
172
|
+
}
|
|
173
|
+
get_fuzzy_url_host_port() {
|
|
174
|
+
var _this$cache17, _this$cache17$fuzzy_u;
|
|
175
|
+
return (_this$cache17$fuzzy_u = (_this$cache17 = this.cache).fuzzy_url_host_port) !== null && _this$cache17$fuzzy_u !== void 0 ? _this$cache17$fuzzy_u : _this$cache17.fuzzy_url_host_port = new RegExp("(?:" + (this.opts.fuzzyIP ? this.get_ipv4_addr().source + "|" : "") + `(?:(?:(?:${this.get_domain().source})\\.){1,10}(?:${this.get_tld().source})))` + this.get_host_terminator().source);
|
|
176
|
+
}
|
|
177
|
+
get_mail_host() {
|
|
178
|
+
var _this$cache18, _this$cache18$src_mai;
|
|
179
|
+
return (_this$cache18$src_mai = (_this$cache18 = this.cache).src_mail_host) !== null && _this$cache18$src_mai !== void 0 ? _this$cache18$src_mai : _this$cache18.src_mail_host = new RegExp("(?:" + this.get_ipv6_mail_host().source + `|(?:(?:(?:${this.get_domain().source})\\.){0,4}${this.get_domain().source}))` + this.get_host_terminator().source);
|
|
180
|
+
}
|
|
181
|
+
get_fuzzy_mail_host() {
|
|
182
|
+
var _this$cache19, _this$cache19$src_fuz;
|
|
183
|
+
return (_this$cache19$src_fuz = (_this$cache19 = this.cache).src_fuzzy_mail_host) !== null && _this$cache19$src_fuz !== void 0 ? _this$cache19$src_fuz : _this$cache19.src_fuzzy_mail_host = new RegExp("(?:" + this.get_ipv6_mail_host().source + `|(?:(?:(?:${this.get_domain().source})[.]){1,4}${this.get_domain_root().source}))` + this.get_host_terminator().source);
|
|
184
|
+
}
|
|
185
|
+
get_path_extra() {
|
|
186
|
+
var _this$cache20, _this$cache20$src_pat;
|
|
187
|
+
return (_this$cache20$src_pat = (_this$cache20 = this.cache).src_path_extra) !== null && _this$cache20$src_pat !== void 0 ? _this$cache20$src_pat : _this$cache20.src_path_extra = /* @__PURE__ */ new RegExp("");
|
|
188
|
+
}
|
|
189
|
+
get_fuzzy_mail_host_search() {
|
|
190
|
+
var _this$cache21, _this$cache21$mail_fu;
|
|
191
|
+
return (_this$cache21$mail_fu = (_this$cache21 = this.cache).mail_fuzzy_host_search) !== null && _this$cache21$mail_fu !== void 0 ? _this$cache21$mail_fu : _this$cache21.mail_fuzzy_host_search = new RegExp(`@${this.get_fuzzy_mail_host().source}`, "ig");
|
|
192
|
+
}
|
|
193
|
+
get_fuzzy_link_search() {
|
|
194
|
+
var _this$cache22, _this$cache22$link_fu;
|
|
195
|
+
return (_this$cache22$link_fu = (_this$cache22 = this.cache).link_fuzzy_search) !== null && _this$cache22$link_fu !== void 0 ? _this$cache22$link_fu : _this$cache22.link_fuzzy_search = new RegExp(`(^|(?![.:/\\-_@])(?:[$+<=>^\`|\uff5c]|${this.src_ZPCc}))(?:(?![$+<=>^\`|\uff5c])${this.get_fuzzy_url_host_port().source}${this.get_path().source})`, "ig");
|
|
196
|
+
}
|
|
197
|
+
get_http_validator() {
|
|
198
|
+
var _this$cache23, _this$cache23$http_va;
|
|
199
|
+
return (_this$cache23$http_va = (_this$cache23 = this.cache).http_validator) !== null && _this$cache23$http_va !== void 0 ? _this$cache23$http_va : _this$cache23.http_validator = new RegExp("\\/\\/" + (this.opts.urlAuth ? this.get_auth().source : "") + this.get_url_host_port().source + this.get_path().source, "iy");
|
|
200
|
+
}
|
|
201
|
+
get_relative_proto_validator() {
|
|
202
|
+
var _this$cache24, _this$cache24$relativ;
|
|
203
|
+
return (_this$cache24$relativ = (_this$cache24 = this.cache).relative_proto_validator) !== null && _this$cache24$relativ !== void 0 ? _this$cache24$relativ : _this$cache24.relative_proto_validator = new RegExp((this.opts.urlAuth ? this.get_auth().source : "") + `(?:localhost|${this.get_ipv6_url_host().source}|(?:(?:${this.get_domain().source})[.]){1,10}${this.get_domain_root().source})` + this.get_port().source + this.get_host_terminator().source + this.get_path().source, "iy");
|
|
204
|
+
}
|
|
205
|
+
get_mail_name_validator() {
|
|
206
|
+
var _this$cache25, _this$cache25$mail_na;
|
|
207
|
+
return (_this$cache25$mail_na = (_this$cache25 = this.cache).mail_name_validator) !== null && _this$cache25$mail_na !== void 0 ? _this$cache25$mail_na : _this$cache25.mail_name_validator = new RegExp(`(?:^|${this.get_text_separators().source}|"|\\(|${this.src_ZCc})(${this.get_mail_name().source})$`);
|
|
208
|
+
}
|
|
209
|
+
get_mailto_validator() {
|
|
210
|
+
var _this$cache26, _this$cache26$mailto_;
|
|
211
|
+
return (_this$cache26$mailto_ = (_this$cache26 = this.cache).mailto_validator) !== null && _this$cache26$mailto_ !== void 0 ? _this$cache26$mailto_ : _this$cache26.mailto_validator = new RegExp(`${this.get_mail_name().source}@${this.get_mail_host().source}`, "iy");
|
|
212
|
+
}
|
|
213
|
+
get_schema_names() {
|
|
214
|
+
var _this$cache27, _this$cache27$schema_;
|
|
215
|
+
return (_this$cache27$schema_ = (_this$cache27 = this.cache).schema_names) !== null && _this$cache27$schema_ !== void 0 ? _this$cache27$schema_ : _this$cache27.schema_names = new RegExp((this.opts.schema_names || []).map((name) => this.escapeRE(name)).join("|"));
|
|
216
|
+
}
|
|
217
|
+
get_schema_search() {
|
|
218
|
+
var _this$cache28, _this$cache28$schema_;
|
|
219
|
+
return (_this$cache28$schema_ = (_this$cache28 = this.cache).schema_search) !== null && _this$cache28$schema_ !== void 0 ? _this$cache28$schema_ : _this$cache28.schema_search = new RegExp(`(^|(?!_)(?:[><\uff5c]|${this.src_ZPCc}))(${this.get_schema_names().source})`, "ig");
|
|
220
|
+
}
|
|
221
|
+
get_schema_at_start() {
|
|
222
|
+
var _this$cache29, _this$cache29$schema_;
|
|
223
|
+
return (_this$cache29$schema_ = (_this$cache29 = this.cache).schema_at_start) !== null && _this$cache29$schema_ !== void 0 ? _this$cache29$schema_ : _this$cache29.schema_at_start = new RegExp(`^${this.get_schema_search().source}`, "i");
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
//#endregion
|
|
227
|
+
//#region \0@oxc-project+runtime@0.138.0/helpers/esm/objectWithoutPropertiesLoose.js
|
|
228
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
229
|
+
if (null == r) return {};
|
|
230
|
+
var t = {};
|
|
231
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
232
|
+
if (e.includes(n)) continue;
|
|
233
|
+
t[n] = r[n];
|
|
234
|
+
}
|
|
235
|
+
return t;
|
|
493
236
|
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
* Creates new linkifier instance with optional additional schemas.
|
|
505
|
-
* Can be called without `new` keyword for convenience.
|
|
506
|
-
*
|
|
507
|
-
* By default understands:
|
|
508
|
-
*
|
|
509
|
-
* - `http(s)://...` , `ftp://...`, `mailto:...` & `//...` links
|
|
510
|
-
* - "fuzzy" links and emails (example.com, foo@bar.com).
|
|
511
|
-
*
|
|
512
|
-
* `schemas` is an object, where each key/value describes protocol/rule:
|
|
513
|
-
*
|
|
514
|
-
* - __key__ - link prefix (usually, protocol name with `:` at the end, `skype:`
|
|
515
|
-
* for example). `linkify-it` makes shure that prefix is not preceeded with
|
|
516
|
-
* alphanumeric char and symbols. Only whitespaces and punctuation allowed.
|
|
517
|
-
* - __value__ - rule to check tail after link prefix
|
|
518
|
-
* - _String_ - just alias to existing rule
|
|
519
|
-
* - _Object_
|
|
520
|
-
* - _validate_ - validator function (should return matched length on success),
|
|
521
|
-
* or `RegExp`.
|
|
522
|
-
* - _normalize_ - optional function to normalize text & url of matched result
|
|
523
|
-
* (for example, for @twitter mentions).
|
|
524
|
-
*
|
|
525
|
-
* `options`:
|
|
526
|
-
*
|
|
527
|
-
* - __fuzzyLink__ - recognige URL-s without `http(s):` prefix. Default `true`.
|
|
528
|
-
* - __fuzzyIP__ - allow IPs in fuzzy links above. Can conflict with some texts
|
|
529
|
-
* like version numbers. Default `false`.
|
|
530
|
-
* - __fuzzyEmail__ - recognize emails without `mailto:` prefix.
|
|
531
|
-
*
|
|
532
|
-
**/
|
|
533
|
-
function LinkifyIt (schemas, options) {
|
|
534
|
-
if (!(this instanceof LinkifyIt)) {
|
|
535
|
-
return new LinkifyIt(schemas, options)
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
if (!options) {
|
|
539
|
-
if (isOptionsObj(schemas)) {
|
|
540
|
-
options = schemas;
|
|
541
|
-
schemas = {};
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
this.__opts__ = assign({}, defaultOptions, options);
|
|
546
|
-
|
|
547
|
-
this.__schemas__ = assign({}, defaultSchemas, schemas);
|
|
548
|
-
this.__compiled__ = {};
|
|
549
|
-
|
|
550
|
-
this.__tlds__ = tlds_default;
|
|
551
|
-
this.__tlds_replaced__ = false;
|
|
552
|
-
|
|
553
|
-
this.re = {};
|
|
554
|
-
|
|
555
|
-
compile(this);
|
|
237
|
+
//#endregion
|
|
238
|
+
//#region \0@oxc-project+runtime@0.138.0/helpers/esm/objectWithoutProperties.js
|
|
239
|
+
function _objectWithoutProperties(e, t) {
|
|
240
|
+
if (null == e) return {};
|
|
241
|
+
var o, r, i = _objectWithoutPropertiesLoose(e, t);
|
|
242
|
+
if (Object.getOwnPropertySymbols) {
|
|
243
|
+
var s = Object.getOwnPropertySymbols(e);
|
|
244
|
+
for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
245
|
+
}
|
|
246
|
+
return i;
|
|
556
247
|
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
return this
|
|
569
|
-
};
|
|
570
|
-
|
|
571
|
-
/** chainable
|
|
572
|
-
* LinkifyIt#set(options)
|
|
573
|
-
* - options (Object): { fuzzyLink|fuzzyEmail|fuzzyIP: true|false }
|
|
574
|
-
*
|
|
575
|
-
* Set recognition options for links without schema.
|
|
576
|
-
**/
|
|
577
|
-
LinkifyIt.prototype.set = function set (options) {
|
|
578
|
-
this.__opts__ = assign(this.__opts__, options);
|
|
579
|
-
return this
|
|
580
|
-
};
|
|
581
|
-
|
|
582
|
-
/**
|
|
583
|
-
* LinkifyIt#test(text) -> Boolean
|
|
584
|
-
*
|
|
585
|
-
* Searches linkifiable pattern and returns `true` on success or `false` on fail.
|
|
586
|
-
**/
|
|
587
|
-
LinkifyIt.prototype.test = function test (text) {
|
|
588
|
-
if (!text.length) { return false }
|
|
589
|
-
|
|
590
|
-
let m, re;
|
|
591
|
-
|
|
592
|
-
// try to scan for link with schema - that's the most simple rule
|
|
593
|
-
if (this.re.schema_test.test(text)) {
|
|
594
|
-
re = this.re.schema_search;
|
|
595
|
-
re.lastIndex = 0;
|
|
596
|
-
while ((m = re.exec(text)) !== null) {
|
|
597
|
-
if (this.testSchemaAt(text, m[2], re.lastIndex)) { return true }
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
if (this.__opts__.fuzzyLink && this.__compiled__['http:']) {
|
|
602
|
-
// guess schemaless links
|
|
603
|
-
if (text.search(this.re.host_fuzzy_test) >= 0) {
|
|
604
|
-
if (text.match(this.__opts__.fuzzyIP ? this.re.link_fuzzy : this.re.link_no_ip_fuzzy) !== null) {
|
|
605
|
-
return true
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
if (this.__opts__.fuzzyEmail && this.__compiled__['mailto:']) {
|
|
611
|
-
// guess schemaless emails
|
|
612
|
-
if (text.indexOf('@') >= 0) {
|
|
613
|
-
// We can't skip this check, because this cases are possible:
|
|
614
|
-
// 192.168.1.1@gmail.com, my.in@example.com
|
|
615
|
-
if (text.match(this.re.email_fuzzy) !== null) { return true }
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
return false
|
|
620
|
-
};
|
|
621
|
-
|
|
622
|
-
/**
|
|
623
|
-
* LinkifyIt#pretest(text) -> Boolean
|
|
624
|
-
*
|
|
625
|
-
* Very quick check, that can give false positives. Returns true if link MAY BE
|
|
626
|
-
* can exists. Can be used for speed optimization, when you need to check that
|
|
627
|
-
* link NOT exists.
|
|
628
|
-
**/
|
|
629
|
-
LinkifyIt.prototype.pretest = function pretest (text) {
|
|
630
|
-
return this.re.pretest.test(text)
|
|
631
|
-
};
|
|
632
|
-
|
|
633
|
-
/**
|
|
634
|
-
* LinkifyIt#testSchemaAt(text, name, position) -> Number
|
|
635
|
-
* - text (String): text to scan
|
|
636
|
-
* - name (String): rule (schema) name
|
|
637
|
-
* - position (Number): text offset to check from
|
|
638
|
-
*
|
|
639
|
-
* Similar to [[LinkifyIt#test]] but checks only specific protocol tail exactly
|
|
640
|
-
* at given position. Returns length of found pattern (0 on fail).
|
|
641
|
-
**/
|
|
642
|
-
LinkifyIt.prototype.testSchemaAt = function testSchemaAt (text, schema, pos) {
|
|
643
|
-
// If not supported schema check requested - terminate
|
|
644
|
-
if (!this.__compiled__[schema.toLowerCase()]) {
|
|
645
|
-
return 0
|
|
646
|
-
}
|
|
647
|
-
return this.__compiled__[schema.toLowerCase()].validate(text, pos, this)
|
|
648
|
-
};
|
|
649
|
-
|
|
650
|
-
/**
|
|
651
|
-
* LinkifyIt#match(text) -> Array|null
|
|
652
|
-
*
|
|
653
|
-
* Returns array of found link descriptions or `null` on fail. We strongly
|
|
654
|
-
* recommend to use [[LinkifyIt#test]] first, for best speed.
|
|
655
|
-
*
|
|
656
|
-
* ##### Result match description
|
|
657
|
-
*
|
|
658
|
-
* - __schema__ - link schema, can be empty for fuzzy links, or `//` for
|
|
659
|
-
* protocol-neutral links.
|
|
660
|
-
* - __index__ - offset of matched text
|
|
661
|
-
* - __lastIndex__ - index of next char after mathch end
|
|
662
|
-
* - __raw__ - matched text
|
|
663
|
-
* - __text__ - normalized text
|
|
664
|
-
* - __url__ - link, generated from matched text
|
|
665
|
-
**/
|
|
666
|
-
LinkifyIt.prototype.match = function match (text) {
|
|
667
|
-
const result = [];
|
|
668
|
-
const type_schemed = [];
|
|
669
|
-
const type_fuzzy_link = [];
|
|
670
|
-
const type_fuzzy_email = [];
|
|
671
|
-
let m, len, re;
|
|
672
|
-
|
|
673
|
-
function choose (a, b) {
|
|
674
|
-
if (!a) { return b }
|
|
675
|
-
if (!b) { return a }
|
|
676
|
-
if (a.index !== b.index) { return a.index < b.index ? a : b }
|
|
677
|
-
return a.lastIndex >= b.lastIndex ? a : b
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
if (!text.length) { return null }
|
|
681
|
-
|
|
682
|
-
// scan for links with schema
|
|
683
|
-
if (this.re.schema_test.test(text)) {
|
|
684
|
-
re = this.re.schema_search;
|
|
685
|
-
re.lastIndex = 0;
|
|
686
|
-
while ((m = re.exec(text)) !== null) {
|
|
687
|
-
len = this.testSchemaAt(text, m[2], re.lastIndex);
|
|
688
|
-
if (len) {
|
|
689
|
-
type_schemed.push({
|
|
690
|
-
schema: m[2],
|
|
691
|
-
index: m.index + m[1].length,
|
|
692
|
-
lastIndex: m.index + m[0].length + len
|
|
693
|
-
});
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
if (this.__opts__.fuzzyLink && this.__compiled__['http:']) {
|
|
699
|
-
re = this.__opts__.fuzzyIP ? this.re.link_fuzzy_global : this.re.link_no_ip_fuzzy_global;
|
|
700
|
-
re.lastIndex = 0;
|
|
701
|
-
while ((m = re.exec(text)) !== null) {
|
|
702
|
-
type_fuzzy_link.push({
|
|
703
|
-
schema: '',
|
|
704
|
-
index: m.index + m[1].length,
|
|
705
|
-
lastIndex: m.index + m[0].length
|
|
706
|
-
});
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
if (this.__opts__.fuzzyEmail && this.__compiled__['mailto:']) {
|
|
711
|
-
re = this.re.email_fuzzy_global;
|
|
712
|
-
re.lastIndex = 0;
|
|
713
|
-
while ((m = re.exec(text)) !== null) {
|
|
714
|
-
type_fuzzy_email.push({
|
|
715
|
-
schema: 'mailto:',
|
|
716
|
-
index: m.index + m[1].length,
|
|
717
|
-
lastIndex: m.index + m[0].length
|
|
718
|
-
});
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
const indexes = [0, 0, 0];
|
|
723
|
-
let lastIndex = 0;
|
|
724
|
-
|
|
725
|
-
for (;;) {
|
|
726
|
-
const candidates = [
|
|
727
|
-
type_schemed[indexes[0]],
|
|
728
|
-
type_fuzzy_email[indexes[1]],
|
|
729
|
-
type_fuzzy_link[indexes[2]]
|
|
730
|
-
];
|
|
731
|
-
|
|
732
|
-
const candidate = choose(choose(candidates[0], candidates[1]), candidates[2]);
|
|
733
|
-
|
|
734
|
-
if (!candidate) { break }
|
|
735
|
-
|
|
736
|
-
if (candidate === candidates[0]) {
|
|
737
|
-
indexes[0]++;
|
|
738
|
-
} else if (candidate === candidates[1]) {
|
|
739
|
-
indexes[1]++;
|
|
740
|
-
} else {
|
|
741
|
-
indexes[2]++;
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
if (candidate.index < lastIndex) { continue }
|
|
745
|
-
|
|
746
|
-
const match = new Match(text, candidate.schema, candidate.index, candidate.lastIndex);
|
|
747
|
-
this.__compiled__[match.schema].normalize(match, this);
|
|
748
|
-
result.push(match);
|
|
749
|
-
lastIndex = candidate.lastIndex;
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
if (result.length) {
|
|
753
|
-
return result
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
return null
|
|
248
|
+
//#endregion
|
|
249
|
+
//#region src/linkifyit.ts
|
|
250
|
+
var _excluded = ["rebuilder"];
|
|
251
|
+
var web_schema = {
|
|
252
|
+
validate: (text, pos, self) => {
|
|
253
|
+
const re = self.re.get_http_validator();
|
|
254
|
+
re.lastIndex = pos;
|
|
255
|
+
const m = re.exec(text);
|
|
256
|
+
return m ? m[0].length : 0;
|
|
257
|
+
},
|
|
258
|
+
normalize: (match, self) => self.normalize(match)
|
|
757
259
|
};
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
260
|
+
var defaultSchemas = {
|
|
261
|
+
"http:": web_schema,
|
|
262
|
+
"https:": web_schema,
|
|
263
|
+
"ftp:": web_schema,
|
|
264
|
+
"//": {
|
|
265
|
+
validate: function(text, pos, self) {
|
|
266
|
+
const re = self.re.get_relative_proto_validator();
|
|
267
|
+
re.lastIndex = pos;
|
|
268
|
+
const m = re.exec(text);
|
|
269
|
+
if (m) {
|
|
270
|
+
if (pos >= 3 && text[pos - 3] === ":") return 0;
|
|
271
|
+
if (pos >= 3 && text[pos - 3] === "/") return 0;
|
|
272
|
+
return m[0].length;
|
|
273
|
+
}
|
|
274
|
+
return 0;
|
|
275
|
+
},
|
|
276
|
+
normalize: (match, self) => self.normalize(match)
|
|
277
|
+
},
|
|
278
|
+
"mailto:": {
|
|
279
|
+
validate: function(text, pos, self) {
|
|
280
|
+
const re = self.re.get_mailto_validator();
|
|
281
|
+
re.lastIndex = pos;
|
|
282
|
+
const m = re.exec(text);
|
|
283
|
+
return m ? m[0].length : 0;
|
|
284
|
+
},
|
|
285
|
+
normalize: (match, self) => self.normalize(match)
|
|
286
|
+
}
|
|
778
287
|
};
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
if (!keepOld) {
|
|
799
|
-
this.__tlds__ = list.slice();
|
|
800
|
-
this.__tlds_replaced__ = true;
|
|
801
|
-
compile(this);
|
|
802
|
-
return this
|
|
803
|
-
}
|
|
804
|
-
|
|
805
|
-
this.__tlds__ = this.__tlds__.concat(list)
|
|
806
|
-
.sort()
|
|
807
|
-
.filter(function (el, idx, arr) {
|
|
808
|
-
return el !== arr[idx - 1]
|
|
809
|
-
})
|
|
810
|
-
.reverse();
|
|
811
|
-
|
|
812
|
-
compile(this);
|
|
813
|
-
return this
|
|
288
|
+
var tlds_2ch = "a:cdefgilmnoqrstuwxz|b:abdefghijmnorstvwyz|c:acdfghiklmnoruvwxyz|d:ejkmoz|e:cegrstu|f:ijkmor|g:abdefghilmnpqrstuwy|h:kmnrtu|i:delmnoqrst|j:emop|k:eghimnprwyz|l:abcikrstuvy|m:acdeghklmnopqrstuvwxyz|n:acefgilopruz|o:m|p:aefghklmnrstwy|q:a|r:eosuw|s:abcdeghijklmnortuvxyz|t:cdfghjklmnortvwz|u:agksyz|v:aceginu|w:fs|y:et|z:amw";
|
|
289
|
+
var tlds_default = "biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф";
|
|
290
|
+
function unpackTlds() {
|
|
291
|
+
const result = tlds_default.split("|");
|
|
292
|
+
tlds_2ch.split("|").forEach((item) => {
|
|
293
|
+
const sep = item.indexOf(":");
|
|
294
|
+
const prefix = item.slice(0, sep);
|
|
295
|
+
for (const suffix of item.slice(sep + 1)) result.push(prefix + suffix);
|
|
296
|
+
});
|
|
297
|
+
return result;
|
|
298
|
+
}
|
|
299
|
+
var defaultOptions = {
|
|
300
|
+
fuzzyLink: false,
|
|
301
|
+
fuzzyEmail: true,
|
|
302
|
+
fuzzyIP: false,
|
|
303
|
+
"---": false,
|
|
304
|
+
tlds: unpackTlds(),
|
|
305
|
+
urlAuth: false,
|
|
306
|
+
maxLength: 1e4
|
|
814
307
|
};
|
|
815
|
-
|
|
816
308
|
/**
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
309
|
+
* Match result returned by {@link LinkifyIt.match} and
|
|
310
|
+
* {@link LinkifyIt.matchAtStart}.
|
|
311
|
+
*
|
|
312
|
+
* @category types
|
|
313
|
+
*/
|
|
314
|
+
var Match = class {
|
|
315
|
+
constructor(text, schema, index, lastIndex) {
|
|
316
|
+
_defineProperty(
|
|
317
|
+
this,
|
|
318
|
+
/** Prefix (protocol) for matched string. Empty for fuzzy links. */
|
|
319
|
+
"schema",
|
|
320
|
+
void 0
|
|
321
|
+
);
|
|
322
|
+
_defineProperty(
|
|
323
|
+
this,
|
|
324
|
+
/** First position of matched string. */
|
|
325
|
+
"index",
|
|
326
|
+
void 0
|
|
327
|
+
);
|
|
328
|
+
_defineProperty(
|
|
329
|
+
this,
|
|
330
|
+
/** Next position after matched string. */
|
|
331
|
+
"lastIndex",
|
|
332
|
+
void 0
|
|
333
|
+
);
|
|
334
|
+
_defineProperty(
|
|
335
|
+
this,
|
|
336
|
+
/** Matched string. */
|
|
337
|
+
"raw",
|
|
338
|
+
void 0
|
|
339
|
+
);
|
|
340
|
+
_defineProperty(
|
|
341
|
+
this,
|
|
342
|
+
/** Normalized text of matched string. */
|
|
343
|
+
"text",
|
|
344
|
+
void 0
|
|
345
|
+
);
|
|
346
|
+
_defineProperty(
|
|
347
|
+
this,
|
|
348
|
+
/** Normalized URL of matched string. */
|
|
349
|
+
"url",
|
|
350
|
+
void 0
|
|
351
|
+
);
|
|
352
|
+
const raw = text.slice(index, lastIndex);
|
|
353
|
+
this.schema = schema.toLowerCase();
|
|
354
|
+
this.index = index;
|
|
355
|
+
this.lastIndex = lastIndex;
|
|
356
|
+
this.raw = raw;
|
|
357
|
+
this.text = raw;
|
|
358
|
+
this.url = raw;
|
|
359
|
+
}
|
|
830
360
|
};
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
361
|
+
/** Linkifier instance. */
|
|
362
|
+
var LinkifyIt = class {
|
|
363
|
+
/**
|
|
364
|
+
* Creates new linkifier instance.
|
|
365
|
+
*
|
|
366
|
+
* By default understands:
|
|
367
|
+
*
|
|
368
|
+
* - `http(s)://...` , `ftp://...`, `mailto:...` & `//...` links
|
|
369
|
+
* - "fuzzy" emails (foo@bar.com).
|
|
370
|
+
*
|
|
371
|
+
* See {@link LinkifyConstructorOptions} for available options.
|
|
372
|
+
*
|
|
373
|
+
* @param options Recognition options.
|
|
374
|
+
*
|
|
375
|
+
* @example
|
|
376
|
+
* ```javascript
|
|
377
|
+
* import { LinkifyIt } from 'linkify-it'
|
|
378
|
+
*
|
|
379
|
+
* const linkify = new LinkifyIt({ fuzzyLink: true })
|
|
380
|
+
*
|
|
381
|
+
* linkify
|
|
382
|
+
* .tlds(require('tlds')) // Reload with full TLD list
|
|
383
|
+
* .tlds('onion', true) // Add unofficial `.onion` domain
|
|
384
|
+
* .add('ftp:', null) // Disable `ftp:` protocol
|
|
385
|
+
* .set({ fuzzyIP: true }) // Enable IPs in fuzzy links
|
|
386
|
+
*
|
|
387
|
+
* console.log(linkify.test('Site github.com!')) // true
|
|
388
|
+
* console.log(linkify.match('Site github.com!'))
|
|
389
|
+
* ```
|
|
390
|
+
*/
|
|
391
|
+
constructor(options = {}) {
|
|
392
|
+
_defineProperty(this, "__opts__", void 0);
|
|
393
|
+
_defineProperty(this, "__schemas__", void 0);
|
|
394
|
+
_defineProperty(this, "re", void 0);
|
|
395
|
+
const { rebuilder } = options, linkifyOptions = _objectWithoutProperties(options, _excluded);
|
|
396
|
+
this.__opts__ = _objectSpread2(_objectSpread2({}, defaultOptions), linkifyOptions);
|
|
397
|
+
this.__schemas__ = _objectSpread2({}, defaultSchemas);
|
|
398
|
+
this.re = rebuilder || new REBuilder();
|
|
399
|
+
this.re.set(_objectSpread2(_objectSpread2({}, this.__opts__), {}, { schema_names: Object.keys(this.__schemas__) }));
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Add new rule definition.
|
|
403
|
+
*
|
|
404
|
+
* `schema` is a link prefix (usually, protocol name with `:` at the end,
|
|
405
|
+
* `skype:` for example). `linkify-it` makes sure that prefix is not
|
|
406
|
+
* preceded with alphanumeric char and symbols. Only whitespaces and
|
|
407
|
+
* punctuation allowed.
|
|
408
|
+
*
|
|
409
|
+
* `definition` is a rule to check tail after link prefix. To disable an
|
|
410
|
+
* existing rule, pass `null`.
|
|
411
|
+
*
|
|
412
|
+
* @param schema Rule name (fixed pattern prefix).
|
|
413
|
+
* @param definition Schema definition, or `null` to disable the rule.
|
|
414
|
+
*
|
|
415
|
+
* See [twitter mentions example](https://github.com/markdown-it/linkify-it/blob/master/examples/twitter.mjs).
|
|
416
|
+
*/
|
|
417
|
+
add(schema, definition = null) {
|
|
418
|
+
if (!definition) delete this.__schemas__[schema];
|
|
419
|
+
else {
|
|
420
|
+
const def = _objectSpread2({ normalize: (match, self) => self.normalize(match) }, definition);
|
|
421
|
+
this.__schemas__[schema] = def;
|
|
422
|
+
}
|
|
423
|
+
this.re.set(_objectSpread2(_objectSpread2({}, this.__opts__), {}, { schema_names: Object.keys(this.__schemas__) }));
|
|
424
|
+
return this;
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Set recognition options for links without schema.
|
|
428
|
+
*
|
|
429
|
+
* @param options Recognition options.
|
|
430
|
+
*/
|
|
431
|
+
set(options = {}) {
|
|
432
|
+
this.__opts__ = _objectSpread2(_objectSpread2({}, this.__opts__), options);
|
|
433
|
+
this.re.set(_objectSpread2(_objectSpread2({}, this.__opts__), {}, { schema_names: Object.keys(this.__schemas__) }));
|
|
434
|
+
return this;
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Searches linkifiable pattern and returns `true` on success or `false` on fail.
|
|
438
|
+
*
|
|
439
|
+
* @param text Text to scan.
|
|
440
|
+
*/
|
|
441
|
+
test(text) {
|
|
442
|
+
if (!text.length) return false;
|
|
443
|
+
let m, re;
|
|
444
|
+
re = this.re.get_schema_search();
|
|
445
|
+
re.lastIndex = 0;
|
|
446
|
+
while ((m = re.exec(text)) !== null) if (this.testSchemaAt(text, m[2], re.lastIndex)) return true;
|
|
447
|
+
if (this.__opts__.fuzzyLink && this.__schemas__["http:"]) {
|
|
448
|
+
re = this.re.get_fuzzy_link_search();
|
|
449
|
+
re.lastIndex = 0;
|
|
450
|
+
if (re.exec(text) !== null) return true;
|
|
451
|
+
}
|
|
452
|
+
if (this.__opts__.fuzzyEmail && this.__schemas__["mailto:"]) {
|
|
453
|
+
if (text.indexOf("@") >= 0) {
|
|
454
|
+
const mailHostRe = this.re.get_fuzzy_mail_host_search();
|
|
455
|
+
const mailNameRe = this.re.get_mail_name_validator();
|
|
456
|
+
mailHostRe.lastIndex = 0;
|
|
457
|
+
while ((m = mailHostRe.exec(text)) !== null) {
|
|
458
|
+
const name = text.slice(Math.max(0, m.index - 65), m.index);
|
|
459
|
+
if (mailNameRe.test(name)) return true;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
return false;
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Similar to {@link LinkifyIt.test} but checks only specific protocol tail exactly
|
|
467
|
+
* at given position. Returns length of found pattern (0 on fail).
|
|
468
|
+
*
|
|
469
|
+
* @param text Text to scan.
|
|
470
|
+
* @param schema Rule (schema) name.
|
|
471
|
+
* @param pos Text offset to check from.
|
|
472
|
+
*/
|
|
473
|
+
testSchemaAt(text, schema, pos) {
|
|
474
|
+
if (!this.__schemas__[schema.toLowerCase()]) return 0;
|
|
475
|
+
return this.__schemas__[schema.toLowerCase()].validate(text.slice(0, pos + this.__opts__.maxLength), pos, this);
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Returns array of found link descriptions or `null` on fail. We strongly
|
|
479
|
+
* recommend to use {@link LinkifyIt.test} first, for best speed.
|
|
480
|
+
*
|
|
481
|
+
* @param text Text to scan.
|
|
482
|
+
*/
|
|
483
|
+
match(text) {
|
|
484
|
+
const result = [];
|
|
485
|
+
const schemaRe = this.re.get_schema_search();
|
|
486
|
+
let fuzzyLinkRe;
|
|
487
|
+
let mailHostRe;
|
|
488
|
+
let mailNameRe;
|
|
489
|
+
let fuzzyLinkCandidate;
|
|
490
|
+
let fuzzyEmailCandidate;
|
|
491
|
+
let schemaPrefix;
|
|
492
|
+
let schemaDone = false;
|
|
493
|
+
let fuzzyLinkDone = false;
|
|
494
|
+
let fuzzyEmailDone = false;
|
|
495
|
+
let pos = 0;
|
|
496
|
+
if (!text.length) return null;
|
|
497
|
+
schemaRe.lastIndex = 0;
|
|
498
|
+
if (this.__opts__.fuzzyLink && this.__schemas__["http:"]) {
|
|
499
|
+
fuzzyLinkRe = this.re.get_fuzzy_link_search();
|
|
500
|
+
fuzzyLinkRe.lastIndex = 0;
|
|
501
|
+
}
|
|
502
|
+
if (this.__opts__.fuzzyEmail && this.__schemas__["mailto:"]) {
|
|
503
|
+
mailHostRe = this.re.get_fuzzy_mail_host_search();
|
|
504
|
+
mailHostRe.lastIndex = 0;
|
|
505
|
+
mailNameRe = this.re.get_mail_name_validator();
|
|
506
|
+
}
|
|
507
|
+
for (;;) {
|
|
508
|
+
const scanFrom = Math.max(pos - 1, 0);
|
|
509
|
+
if (mailHostRe && mailNameRe && !fuzzyEmailDone && (!fuzzyEmailCandidate || fuzzyEmailCandidate.index < pos)) {
|
|
510
|
+
if (mailHostRe.lastIndex < scanFrom) mailHostRe.lastIndex = scanFrom;
|
|
511
|
+
for (;;) {
|
|
512
|
+
const m = mailHostRe.exec(text);
|
|
513
|
+
if (!m) {
|
|
514
|
+
fuzzyEmailDone = true;
|
|
515
|
+
fuzzyEmailCandidate = void 0;
|
|
516
|
+
break;
|
|
517
|
+
}
|
|
518
|
+
const name = mailNameRe.exec(text.slice(Math.max(0, m.index - 65), m.index));
|
|
519
|
+
if (!name) continue;
|
|
520
|
+
fuzzyEmailCandidate = {
|
|
521
|
+
schema: "mailto:",
|
|
522
|
+
index: m.index - name[1].length,
|
|
523
|
+
lastIndex: m.index + m[0].length
|
|
524
|
+
};
|
|
525
|
+
if (fuzzyEmailCandidate.index >= pos) break;
|
|
526
|
+
if (mailHostRe.lastIndex < scanFrom) mailHostRe.lastIndex = scanFrom;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
if (fuzzyLinkRe && !fuzzyLinkDone && (!fuzzyLinkCandidate || fuzzyLinkCandidate.index < pos)) {
|
|
530
|
+
if (fuzzyLinkRe.lastIndex < scanFrom) fuzzyLinkRe.lastIndex = scanFrom;
|
|
531
|
+
for (;;) {
|
|
532
|
+
const m = fuzzyLinkRe.exec(text);
|
|
533
|
+
if (!m) {
|
|
534
|
+
fuzzyLinkDone = true;
|
|
535
|
+
fuzzyLinkCandidate = void 0;
|
|
536
|
+
break;
|
|
537
|
+
}
|
|
538
|
+
fuzzyLinkCandidate = {
|
|
539
|
+
schema: "",
|
|
540
|
+
index: m.index + m[1].length,
|
|
541
|
+
lastIndex: m.index + m[0].length
|
|
542
|
+
};
|
|
543
|
+
if (fuzzyLinkCandidate.index >= pos) break;
|
|
544
|
+
if (fuzzyLinkRe.lastIndex < scanFrom) fuzzyLinkRe.lastIndex = scanFrom;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
let fuzzyCandidate = fuzzyEmailCandidate;
|
|
548
|
+
if (!fuzzyCandidate || fuzzyLinkCandidate && (fuzzyLinkCandidate.index < fuzzyCandidate.index || fuzzyLinkCandidate.index === fuzzyCandidate.index && fuzzyLinkCandidate.lastIndex > fuzzyCandidate.lastIndex)) fuzzyCandidate = fuzzyLinkCandidate;
|
|
549
|
+
let schemaCandidate;
|
|
550
|
+
if (!schemaDone) for (;;) {
|
|
551
|
+
if (!schemaPrefix) {
|
|
552
|
+
if (schemaRe.lastIndex < scanFrom) schemaRe.lastIndex = scanFrom;
|
|
553
|
+
const m = schemaRe.exec(text);
|
|
554
|
+
if (!m) {
|
|
555
|
+
schemaDone = true;
|
|
556
|
+
break;
|
|
557
|
+
}
|
|
558
|
+
schemaPrefix = {
|
|
559
|
+
schema: m[2],
|
|
560
|
+
index: m.index + m[1].length,
|
|
561
|
+
lastIndex: m.index + m[0].length
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
if (schemaPrefix.index < pos) {
|
|
565
|
+
schemaPrefix = void 0;
|
|
566
|
+
continue;
|
|
567
|
+
}
|
|
568
|
+
if (fuzzyCandidate && schemaPrefix.index > fuzzyCandidate.index) break;
|
|
569
|
+
const prefix = schemaPrefix;
|
|
570
|
+
schemaPrefix = void 0;
|
|
571
|
+
const len = this.testSchemaAt(text, prefix.schema, prefix.lastIndex);
|
|
572
|
+
if (len) {
|
|
573
|
+
schemaCandidate = {
|
|
574
|
+
schema: prefix.schema,
|
|
575
|
+
index: prefix.index,
|
|
576
|
+
lastIndex: prefix.lastIndex + len
|
|
577
|
+
};
|
|
578
|
+
break;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
let candidate = schemaCandidate;
|
|
582
|
+
if (!candidate || fuzzyEmailCandidate && (fuzzyEmailCandidate.index < candidate.index || fuzzyEmailCandidate.index === candidate.index && fuzzyEmailCandidate.lastIndex > candidate.lastIndex)) candidate = fuzzyEmailCandidate;
|
|
583
|
+
if (!candidate || fuzzyLinkCandidate && (fuzzyLinkCandidate.index < candidate.index || fuzzyLinkCandidate.index === candidate.index && fuzzyLinkCandidate.lastIndex > candidate.lastIndex)) candidate = fuzzyLinkCandidate;
|
|
584
|
+
if (!candidate) break;
|
|
585
|
+
if (candidate === fuzzyEmailCandidate) fuzzyEmailCandidate = void 0;
|
|
586
|
+
else if (candidate === fuzzyLinkCandidate) fuzzyLinkCandidate = void 0;
|
|
587
|
+
const match = new Match(text, candidate.schema, candidate.index, candidate.lastIndex);
|
|
588
|
+
if (match.schema) this.__schemas__[match.schema].normalize(match, this);
|
|
589
|
+
else this.normalize(match);
|
|
590
|
+
result.push(match);
|
|
591
|
+
pos = candidate.lastIndex;
|
|
592
|
+
}
|
|
593
|
+
if (result.length) return result;
|
|
594
|
+
return null;
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* Returns fully-formed (not fuzzy) link if it starts at the beginning
|
|
598
|
+
* of the string, and null otherwise.
|
|
599
|
+
*
|
|
600
|
+
* @param text Text to scan.
|
|
601
|
+
*/
|
|
602
|
+
matchAtStart(text) {
|
|
603
|
+
if (!text.length) return null;
|
|
604
|
+
const m = this.re.get_schema_at_start().exec(text);
|
|
605
|
+
if (!m) return null;
|
|
606
|
+
const len = this.testSchemaAt(text, m[2], m[0].length);
|
|
607
|
+
if (!len) return null;
|
|
608
|
+
const match = new Match(text, m[2], m.index + m[1].length, m.index + m[0].length + len);
|
|
609
|
+
this.__schemas__[match.schema].normalize(match, this);
|
|
610
|
+
return match;
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Load (or merge) new TLDs list. Those are used for fuzzy links (without
|
|
614
|
+
* prefix) to avoid false positives. By default this algorithm is used:
|
|
615
|
+
*
|
|
616
|
+
* - hostname with any 2-letter root zones are ok.
|
|
617
|
+
* - biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф
|
|
618
|
+
* are ok.
|
|
619
|
+
* - encoded (`xn--...`) root zones are ok.
|
|
620
|
+
*
|
|
621
|
+
* If list is replaced, then exact match for 2-chars root zones will be checked.
|
|
622
|
+
*
|
|
623
|
+
* @param list List of TLDs.
|
|
624
|
+
* @param keepOld Merge with current list if `true` (`false` by default).
|
|
625
|
+
*/
|
|
626
|
+
tlds(list, keepOld = false) {
|
|
627
|
+
list = Array.isArray(list) ? list : [list];
|
|
628
|
+
if (!keepOld) this.__opts__.tlds = list;
|
|
629
|
+
else this.__opts__.tlds = this.__opts__.tlds.concat(list);
|
|
630
|
+
this.re.set(_objectSpread2(_objectSpread2({}, this.__opts__), {}, { schema_names: Object.keys(this.__schemas__) }));
|
|
631
|
+
return this;
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Default normalizer (if schema does not define its own).
|
|
635
|
+
*
|
|
636
|
+
* @param match Match to normalize.
|
|
637
|
+
*/
|
|
638
|
+
normalize(match) {
|
|
639
|
+
if (!match.schema) match.url = `http://${match.url}`;
|
|
640
|
+
if (match.schema === "mailto:" && !/^mailto:/i.test(match.url)) match.url = `mailto:${match.url}`;
|
|
641
|
+
}
|
|
838
642
|
};
|
|
643
|
+
function linkifyit(options = {}) {
|
|
644
|
+
return new LinkifyIt(options);
|
|
645
|
+
}
|
|
646
|
+
//#endregion
|
|
647
|
+
exports.LinkifyIt = LinkifyIt;
|
|
648
|
+
exports.REBuilder = REBuilder;
|
|
649
|
+
exports.linkifyit = linkifyit;
|
|
839
650
|
|
|
840
|
-
|
|
651
|
+
//# sourceMappingURL=index.cjs.js.map
|