n4s 5.0.1 → 5.0.2

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.
Files changed (80) hide show
  1. package/CHANGELOG.md +0 -4
  2. package/README.md +2 -0
  3. package/compose/package.json +2 -0
  4. package/compounds/package.json +2 -0
  5. package/date/package.json +9 -0
  6. package/dist/cjs/compose.development.js +14 -97
  7. package/dist/cjs/compose.js +0 -1
  8. package/dist/cjs/compose.production.js +1 -1
  9. package/dist/cjs/compounds.development.js +30 -86
  10. package/dist/cjs/compounds.js +0 -1
  11. package/dist/cjs/compounds.production.js +1 -1
  12. package/dist/cjs/date.development.js +186 -0
  13. package/dist/cjs/date.js +6 -0
  14. package/dist/cjs/date.production.js +1 -0
  15. package/dist/cjs/email.development.js +363 -0
  16. package/dist/cjs/email.js +6 -0
  17. package/dist/cjs/email.production.js +1 -0
  18. package/dist/cjs/isURL.development.js +353 -0
  19. package/dist/cjs/isURL.js +6 -0
  20. package/dist/cjs/isURL.production.js +1 -0
  21. package/dist/cjs/n4s.development.js +205 -387
  22. package/dist/cjs/n4s.js +0 -1
  23. package/dist/cjs/n4s.production.js +1 -1
  24. package/dist/cjs/schema.development.js +19 -80
  25. package/dist/cjs/schema.js +0 -1
  26. package/dist/cjs/schema.production.js +1 -1
  27. package/dist/es/compose.development.js +14 -97
  28. package/dist/es/compose.production.js +1 -1
  29. package/dist/es/compounds.development.js +28 -84
  30. package/dist/es/compounds.production.js +1 -1
  31. package/dist/es/date.development.js +184 -0
  32. package/dist/es/date.production.js +1 -0
  33. package/dist/es/email.development.js +361 -0
  34. package/dist/es/email.production.js +1 -0
  35. package/dist/es/isURL.development.js +351 -0
  36. package/dist/es/isURL.production.js +1 -0
  37. package/dist/es/n4s.development.js +192 -372
  38. package/dist/es/n4s.production.js +1 -1
  39. package/dist/es/schema.development.js +16 -75
  40. package/dist/es/schema.production.js +1 -1
  41. package/dist/umd/compose.development.js +18 -102
  42. package/dist/umd/compose.production.js +1 -1
  43. package/dist/umd/compounds.development.js +34 -91
  44. package/dist/umd/compounds.production.js +1 -1
  45. package/dist/umd/date.development.js +190 -0
  46. package/dist/umd/date.production.js +1 -0
  47. package/dist/umd/email.development.js +367 -0
  48. package/dist/umd/email.production.js +1 -0
  49. package/dist/umd/isURL.development.js +357 -0
  50. package/dist/umd/isURL.production.js +1 -0
  51. package/dist/umd/n4s.development.js +209 -392
  52. package/dist/umd/n4s.production.js +1 -1
  53. package/dist/umd/schema.development.js +23 -85
  54. package/dist/umd/schema.production.js +1 -1
  55. package/email/package.json +9 -0
  56. package/isURL/package.json +9 -0
  57. package/package.json +162 -55
  58. package/schema/package.json +2 -0
  59. package/testUtils/TEnforceMock.ts +3 -0
  60. package/types/compose.d.ts +46 -55
  61. package/types/compose.d.ts.map +1 -0
  62. package/types/compounds.d.ts +50 -62
  63. package/types/compounds.d.ts.map +1 -0
  64. package/types/date.d.ts +18 -0
  65. package/types/date.d.ts.map +1 -0
  66. package/types/email.d.ts +12 -0
  67. package/types/email.d.ts.map +1 -0
  68. package/types/isURL.d.ts +12 -0
  69. package/types/isURL.d.ts.map +1 -0
  70. package/types/n4s.d.ts +62 -73
  71. package/types/n4s.d.ts.map +1 -0
  72. package/types/schema.d.ts +55 -63
  73. package/types/schema.d.ts.map +1 -0
  74. package/docs/.nojekyll +0 -0
  75. package/docs/README.md +0 -44
  76. package/docs/_sidebar.md +0 -5
  77. package/docs/external.md +0 -27
  78. package/docs/index.html +0 -32
  79. package/docs/rules.md +0 -1282
  80. package/tsconfig.json +0 -8
@@ -0,0 +1,353 @@
1
+ 'use strict';
2
+
3
+ var n4s = require('n4s');
4
+
5
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
6
+
7
+ function assertString(input) {
8
+ var isString = typeof input === 'string' || input instanceof String;
9
+
10
+ if (!isString) {
11
+ var invalidType = _typeof(input);
12
+
13
+ if (input === null) invalidType = 'null';else if (invalidType === 'object') invalidType = input.constructor.name;
14
+ throw new TypeError("Expected a string but received a ".concat(invalidType));
15
+ }
16
+ }
17
+
18
+ function merge() {
19
+ var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
20
+ var defaults = arguments.length > 1 ? arguments[1] : undefined;
21
+
22
+ for (var key in defaults) {
23
+ if (typeof obj[key] === 'undefined') {
24
+ obj[key] = defaults[key];
25
+ }
26
+ }
27
+
28
+ return obj;
29
+ }
30
+
31
+ var default_fqdn_options = {
32
+ require_tld: true,
33
+ allow_underscores: false,
34
+ allow_trailing_dot: false,
35
+ allow_numeric_tld: false,
36
+ allow_wildcard: false,
37
+ ignore_max_length: false
38
+ };
39
+ function isFQDN(str, options) {
40
+ assertString(str);
41
+ options = merge(options, default_fqdn_options);
42
+ /* Remove the optional trailing dot before checking validity */
43
+
44
+ if (options.allow_trailing_dot && str[str.length - 1] === '.') {
45
+ str = str.substring(0, str.length - 1);
46
+ }
47
+ /* Remove the optional wildcard before checking validity */
48
+
49
+
50
+ if (options.allow_wildcard === true && str.indexOf('*.') === 0) {
51
+ str = str.substring(2);
52
+ }
53
+
54
+ var parts = str.split('.');
55
+ var tld = parts[parts.length - 1];
56
+
57
+ if (options.require_tld) {
58
+ // disallow fqdns without tld
59
+ if (parts.length < 2) {
60
+ return false;
61
+ }
62
+
63
+ if (!options.allow_numeric_tld && !/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) {
64
+ return false;
65
+ } // disallow spaces
66
+
67
+
68
+ if (/\s/.test(tld)) {
69
+ return false;
70
+ }
71
+ } // reject numeric TLDs
72
+
73
+
74
+ if (!options.allow_numeric_tld && /^\d+$/.test(tld)) {
75
+ return false;
76
+ }
77
+
78
+ return parts.every(function (part) {
79
+ if (part.length > 63 && !options.ignore_max_length) {
80
+ return false;
81
+ }
82
+
83
+ if (!/^[a-z_\u00a1-\uffff0-9-]+$/i.test(part)) {
84
+ return false;
85
+ } // disallow full-width chars
86
+
87
+
88
+ if (/[\uff01-\uff5e]/.test(part)) {
89
+ return false;
90
+ } // disallow parts starting or ending with hyphen
91
+
92
+
93
+ if (/^-|-$/.test(part)) {
94
+ return false;
95
+ }
96
+
97
+ if (!options.allow_underscores && /_/.test(part)) {
98
+ return false;
99
+ }
100
+
101
+ return true;
102
+ });
103
+ }
104
+
105
+ /**
106
+ 11.3. Examples
107
+
108
+ The following addresses
109
+
110
+ fe80::1234 (on the 1st link of the node)
111
+ ff02::5678 (on the 5th link of the node)
112
+ ff08::9abc (on the 10th organization of the node)
113
+
114
+ would be represented as follows:
115
+
116
+ fe80::1234%1
117
+ ff02::5678%5
118
+ ff08::9abc%10
119
+
120
+ (Here we assume a natural translation from a zone index to the
121
+ <zone_id> part, where the Nth zone of any scope is translated into
122
+ "N".)
123
+
124
+ If we use interface names as <zone_id>, those addresses could also be
125
+ represented as follows:
126
+
127
+ fe80::1234%ne0
128
+ ff02::5678%pvc1.3
129
+ ff08::9abc%interface10
130
+
131
+ where the interface "ne0" belongs to the 1st link, "pvc1.3" belongs
132
+ to the 5th link, and "interface10" belongs to the 10th organization.
133
+ * * */
134
+
135
+ var IPv4SegmentFormat = '(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])';
136
+ var IPv4AddressFormat = "(".concat(IPv4SegmentFormat, "[.]){3}").concat(IPv4SegmentFormat);
137
+ var IPv4AddressRegExp = new RegExp("^".concat(IPv4AddressFormat, "$"));
138
+ var IPv6SegmentFormat = '(?:[0-9a-fA-F]{1,4})';
139
+ var IPv6AddressRegExp = new RegExp('^(' + "(?:".concat(IPv6SegmentFormat, ":){7}(?:").concat(IPv6SegmentFormat, "|:)|") + "(?:".concat(IPv6SegmentFormat, ":){6}(?:").concat(IPv4AddressFormat, "|:").concat(IPv6SegmentFormat, "|:)|") + "(?:".concat(IPv6SegmentFormat, ":){5}(?::").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,2}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){4}(?:(:").concat(IPv6SegmentFormat, "){0,1}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,3}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){3}(?:(:").concat(IPv6SegmentFormat, "){0,2}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,4}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){2}(?:(:").concat(IPv6SegmentFormat, "){0,3}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,5}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){1}(?:(:").concat(IPv6SegmentFormat, "){0,4}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,6}|:)|") + "(?::((?::".concat(IPv6SegmentFormat, "){0,5}:").concat(IPv4AddressFormat, "|(?::").concat(IPv6SegmentFormat, "){1,7}|:))") + ')(%[0-9a-zA-Z-.:]{1,})?$');
140
+ function isIP(str) {
141
+ var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
142
+ assertString(str);
143
+ version = String(version);
144
+
145
+ if (!version) {
146
+ return isIP(str, 4) || isIP(str, 6);
147
+ }
148
+
149
+ if (version === '4') {
150
+ return IPv4AddressRegExp.test(str);
151
+ }
152
+
153
+ if (version === '6') {
154
+ return IPv6AddressRegExp.test(str);
155
+ }
156
+
157
+ return false;
158
+ }
159
+
160
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
161
+
162
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
163
+
164
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
165
+
166
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
167
+
168
+ function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
169
+
170
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
171
+ /*
172
+ options for isURL method
173
+
174
+ require_protocol - if set as true isURL will return false if protocol is not present in the URL
175
+ require_valid_protocol - isURL will check if the URL's protocol is present in the protocols option
176
+ protocols - valid protocols can be modified with this option
177
+ require_host - if set as false isURL will not check if host is present in the URL
178
+ require_port - if set as true isURL will check if port is present in the URL
179
+ allow_protocol_relative_urls - if set as true protocol relative URLs will be allowed
180
+ validate_length - if set as false isURL will skip string length validation (IE maximum is 2083)
181
+
182
+ */
183
+
184
+ var default_url_options = {
185
+ protocols: ['http', 'https', 'ftp'],
186
+ require_tld: true,
187
+ require_protocol: false,
188
+ require_host: true,
189
+ require_port: false,
190
+ require_valid_protocol: true,
191
+ allow_underscores: false,
192
+ allow_trailing_dot: false,
193
+ allow_protocol_relative_urls: false,
194
+ allow_fragments: true,
195
+ allow_query_components: true,
196
+ validate_length: true
197
+ };
198
+ var wrapped_ipv6 = /^\[([^\]]+)\](?::([0-9]+))?$/;
199
+
200
+ function isRegExp(obj) {
201
+ return Object.prototype.toString.call(obj) === '[object RegExp]';
202
+ }
203
+
204
+ function checkHost(host, matches) {
205
+ for (var i = 0; i < matches.length; i++) {
206
+ var match = matches[i];
207
+
208
+ if (host === match || isRegExp(match) && match.test(host)) {
209
+ return true;
210
+ }
211
+ }
212
+
213
+ return false;
214
+ }
215
+
216
+ function isURL(url, options) {
217
+ assertString(url);
218
+
219
+ if (!url || /[\s<>]/.test(url)) {
220
+ return false;
221
+ }
222
+
223
+ if (url.indexOf('mailto:') === 0) {
224
+ return false;
225
+ }
226
+
227
+ options = merge(options, default_url_options);
228
+
229
+ if (options.validate_length && url.length >= 2083) {
230
+ return false;
231
+ }
232
+
233
+ if (!options.allow_fragments && url.includes('#')) {
234
+ return false;
235
+ }
236
+
237
+ if (!options.allow_query_components && (url.includes('?') || url.includes('&'))) {
238
+ return false;
239
+ }
240
+
241
+ var protocol, auth, host, hostname, port, port_str, split, ipv6;
242
+ split = url.split('#');
243
+ url = split.shift();
244
+ split = url.split('?');
245
+ url = split.shift();
246
+ split = url.split('://');
247
+
248
+ if (split.length > 1) {
249
+ protocol = split.shift().toLowerCase();
250
+
251
+ if (options.require_valid_protocol && options.protocols.indexOf(protocol) === -1) {
252
+ return false;
253
+ }
254
+ } else if (options.require_protocol) {
255
+ return false;
256
+ } else if (url.slice(0, 2) === '//') {
257
+ if (!options.allow_protocol_relative_urls) {
258
+ return false;
259
+ }
260
+
261
+ split[0] = url.slice(2);
262
+ }
263
+
264
+ url = split.join('://');
265
+
266
+ if (url === '') {
267
+ return false;
268
+ }
269
+
270
+ split = url.split('/');
271
+ url = split.shift();
272
+
273
+ if (url === '' && !options.require_host) {
274
+ return true;
275
+ }
276
+
277
+ split = url.split('@');
278
+
279
+ if (split.length > 1) {
280
+ if (options.disallow_auth) {
281
+ return false;
282
+ }
283
+
284
+ if (split[0] === '') {
285
+ return false;
286
+ }
287
+
288
+ auth = split.shift();
289
+
290
+ if (auth.indexOf(':') >= 0 && auth.split(':').length > 2) {
291
+ return false;
292
+ }
293
+
294
+ var _auth$split = auth.split(':'),
295
+ _auth$split2 = _slicedToArray(_auth$split, 2),
296
+ user = _auth$split2[0],
297
+ password = _auth$split2[1];
298
+
299
+ if (user === '' && password === '') {
300
+ return false;
301
+ }
302
+ }
303
+
304
+ hostname = split.join('@');
305
+ port_str = null;
306
+ ipv6 = null;
307
+ var ipv6_match = hostname.match(wrapped_ipv6);
308
+
309
+ if (ipv6_match) {
310
+ host = '';
311
+ ipv6 = ipv6_match[1];
312
+ port_str = ipv6_match[2] || null;
313
+ } else {
314
+ split = hostname.split(':');
315
+ host = split.shift();
316
+
317
+ if (split.length) {
318
+ port_str = split.join(':');
319
+ }
320
+ }
321
+
322
+ if (port_str !== null && port_str.length > 0) {
323
+ port = parseInt(port_str, 10);
324
+
325
+ if (!/^[0-9]+$/.test(port_str) || port <= 0 || port > 65535) {
326
+ return false;
327
+ }
328
+ } else if (options.require_port) {
329
+ return false;
330
+ }
331
+
332
+ if (options.host_whitelist) {
333
+ return checkHost(host, options.host_whitelist);
334
+ }
335
+
336
+ if (host === '' && !options.require_host) {
337
+ return true;
338
+ }
339
+
340
+ if (!isIP(host) && !isFQDN(host, options) && (!ipv6 || !isIP(ipv6, 6))) {
341
+ return false;
342
+ }
343
+
344
+ host = host || ipv6;
345
+
346
+ if (options.host_blacklist && checkHost(host, options.host_blacklist)) {
347
+ return false;
348
+ }
349
+
350
+ return true;
351
+ }
352
+
353
+ n4s.enforce.extend({ isURL });
@@ -0,0 +1,6 @@
1
+ 'use strict'
2
+ if (process.env.NODE_ENV === 'production') {
3
+ module.exports = require('./isURL.production.js');
4
+ } else {
5
+ module.exports = require('./isURL.development.js');
6
+ }
@@ -0,0 +1 @@
1
+ "use strict";var t=require("n4s");function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function e(t){if(!("string"==typeof t||t instanceof String)){var e=r(t);throw null===t?e="null":"object"===e&&(e=t.constructor.name),new TypeError("Expected a string but received a ".concat(e))}}function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;for(var e in r)void 0===t[e]&&(t[e]=r[e]);return t}var o={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_numeric_tld:!1,allow_wildcard:!1,ignore_max_length:!1};var i="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",l="(".concat(i,"[.]){3}").concat(i),c=new RegExp("^".concat(l,"$")),a="(?:[0-9a-fA-F]{1,4})",u=new RegExp("^("+"(?:".concat(a,":){7}(?:").concat(a,"|:)|")+"(?:".concat(a,":){6}(?:").concat(l,"|:").concat(a,"|:)|")+"(?:".concat(a,":){5}(?::").concat(l,"|(:").concat(a,"){1,2}|:)|")+"(?:".concat(a,":){4}(?:(:").concat(a,"){0,1}:").concat(l,"|(:").concat(a,"){1,3}|:)|")+"(?:".concat(a,":){3}(?:(:").concat(a,"){0,2}:").concat(l,"|(:").concat(a,"){1,4}|:)|")+"(?:".concat(a,":){2}(?:(:").concat(a,"){0,3}:").concat(l,"|(:").concat(a,"){1,5}|:)|")+"(?:".concat(a,":){1}(?:(:").concat(a,"){0,4}:").concat(l,"|(:").concat(a,"){1,6}|:)|")+"(?::((?::".concat(a,"){0,5}:").concat(l,"|(?::").concat(a,"){1,7}|:))")+")(%[0-9a-zA-Z-.:]{1,})?$");function s(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return e(t),(r=String(r))?"4"===r?c.test(t):"6"===r&&u.test(t):s(t,4)||s(t,6)}function f(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var e=[],n=!0,o=!1,i=void 0;try{for(var l,c=t[Symbol.iterator]();!(n=(l=c.next()).done)&&(e.push(l.value),!r||e.length!==r);n=!0);}catch(t){o=!0,i=t}finally{try{n||null==c.return||c.return()}finally{if(o)throw i}}return e}(t,r)||function(t,r){if(!t)return;if("string"==typeof t)return _(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);"Object"===e&&t.constructor&&(e=t.constructor.name);if("Map"===e||"Set"===e)return Array.from(t);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return _(t,r)}(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}var p={protocols:["http","https","ftp"],require_tld:!0,require_protocol:!1,require_host:!0,require_port:!1,require_valid_protocol:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_protocol_relative_urls:!1,allow_fragments:!0,allow_query_components:!0,validate_length:!0},h=/^\[([^\]]+)\](?::([0-9]+))?$/;function d(t,r){for(var e=0;e<r.length;e++){var n=r[e];if(t===n||(o=n,"[object RegExp]"===Object.prototype.toString.call(o)&&n.test(t)))return!0}var o;return!1}t.enforce.extend({isURL:function(t,r){if(e(t),!t||/[\s<>]/.test(t))return!1;if(0===t.indexOf("mailto:"))return!1;if((r=n(r,p)).validate_length&&t.length>=2083)return!1;if(!r.allow_fragments&&t.includes("#"))return!1;if(!r.allow_query_components&&(t.includes("?")||t.includes("&")))return!1;var i,l,c,a,u,_,g,y;if(g=t.split("#"),t=g.shift(),g=t.split("?"),t=g.shift(),(g=t.split("://")).length>1){if(i=g.shift().toLowerCase(),r.require_valid_protocol&&-1===r.protocols.indexOf(i))return!1}else{if(r.require_protocol)return!1;if("//"===t.slice(0,2)){if(!r.allow_protocol_relative_urls)return!1;g[0]=t.slice(2)}}if(""===(t=g.join("://")))return!1;if(g=t.split("/"),""===(t=g.shift())&&!r.require_host)return!0;if((g=t.split("@")).length>1){if(r.disallow_auth)return!1;if(""===g[0])return!1;if((l=g.shift()).indexOf(":")>=0&&l.split(":").length>2)return!1;var v=f(l.split(":"),2),w=v[0],m=v[1];if(""===w&&""===m)return!1}_=null,y=null;var b=(a=g.join("@")).match(h);if(b?(c="",y=b[1],_=b[2]||null):(c=(g=a.split(":")).shift(),g.length&&(_=g.join(":"))),null!==_&&_.length>0){if(u=parseInt(_,10),!/^[0-9]+$/.test(_)||u<=0||u>65535)return!1}else if(r.require_port)return!1;return r.host_whitelist?d(c,r.host_whitelist):""===c&&!r.require_host||!!(s(c)||function(t,r){e(t),(r=n(r,o)).allow_trailing_dot&&"."===t[t.length-1]&&(t=t.substring(0,t.length-1)),!0===r.allow_wildcard&&0===t.indexOf("*.")&&(t=t.substring(2));var i=t.split("."),l=i[i.length-1];if(r.require_tld){if(i.length<2)return!1;if(!r.allow_numeric_tld&&!/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(l))return!1;if(/\s/.test(l))return!1}return!(!r.allow_numeric_tld&&/^\d+$/.test(l))&&i.every((function(t){return!(t.length>63&&!r.ignore_max_length||!/^[a-z_\u00a1-\uffff0-9-]+$/i.test(t)||/[\uff01-\uff5e]/.test(t)||/^-|-$/.test(t)||!r.allow_underscores&&/_/.test(t))}))}(c,r)||y&&s(y,6))&&(c=c||y,!r.host_blacklist||!d(c,r.host_blacklist))}});