@pack/hydrogen 2.1.0 → 2.1.1

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/dist/index.js CHANGED
@@ -1317,75 +1317,99 @@ var require_ua_parser = __commonJS({
1317
1317
  }
1318
1318
  });
1319
1319
 
1320
- // node_modules/cookie/index.js
1320
+ // ../../node_modules/cookie/index.js
1321
1321
  var require_cookie = __commonJS({
1322
- "node_modules/cookie/index.js"(exports) {
1322
+ "../../node_modules/cookie/index.js"(exports) {
1323
1323
  "use strict";
1324
1324
  exports.parse = parse2;
1325
1325
  exports.serialize = serialize2;
1326
1326
  var __toString = Object.prototype.toString;
1327
- var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
1328
- function parse2(str, options) {
1327
+ var __hasOwnProperty = Object.prototype.hasOwnProperty;
1328
+ var cookieNameRegExp = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
1329
+ var cookieValueRegExp = /^("?)[\u0021\u0023-\u002B\u002D-\u003A\u003C-\u005B\u005D-\u007E]*\1$/;
1330
+ var domainValueRegExp = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i;
1331
+ var pathValueRegExp = /^[\u0020-\u003A\u003D-\u007E]*$/;
1332
+ function parse2(str, opt) {
1329
1333
  if (typeof str !== "string") {
1330
1334
  throw new TypeError("argument str must be a string");
1331
1335
  }
1332
1336
  var obj = {};
1333
- var opt = options || {};
1334
- var dec = opt.decode || decode;
1337
+ var len = str.length;
1338
+ if (len < 2) return obj;
1339
+ var dec = opt && opt.decode || decode;
1335
1340
  var index = 0;
1336
- while (index < str.length) {
1337
- var eqIdx = str.indexOf("=", index);
1338
- if (eqIdx === -1) {
1339
- break;
1340
- }
1341
- var endIdx = str.indexOf(";", index);
1341
+ var eqIdx = 0;
1342
+ var endIdx = 0;
1343
+ do {
1344
+ eqIdx = str.indexOf("=", index);
1345
+ if (eqIdx === -1) break;
1346
+ endIdx = str.indexOf(";", index);
1342
1347
  if (endIdx === -1) {
1343
- endIdx = str.length;
1344
- } else if (endIdx < eqIdx) {
1348
+ endIdx = len;
1349
+ } else if (eqIdx > endIdx) {
1345
1350
  index = str.lastIndexOf(";", eqIdx - 1) + 1;
1346
1351
  continue;
1347
1352
  }
1348
- var key = str.slice(index, eqIdx).trim();
1349
- if (void 0 === obj[key]) {
1350
- var val = str.slice(eqIdx + 1, endIdx).trim();
1351
- if (val.charCodeAt(0) === 34) {
1352
- val = val.slice(1, -1);
1353
+ var keyStartIdx = startIndex(str, index, eqIdx);
1354
+ var keyEndIdx = endIndex(str, eqIdx, keyStartIdx);
1355
+ var key = str.slice(keyStartIdx, keyEndIdx);
1356
+ if (!__hasOwnProperty.call(obj, key)) {
1357
+ var valStartIdx = startIndex(str, eqIdx + 1, endIdx);
1358
+ var valEndIdx = endIndex(str, endIdx, valStartIdx);
1359
+ if (str.charCodeAt(valStartIdx) === 34 && str.charCodeAt(valEndIdx - 1) === 34) {
1360
+ valStartIdx++;
1361
+ valEndIdx--;
1353
1362
  }
1363
+ var val = str.slice(valStartIdx, valEndIdx);
1354
1364
  obj[key] = tryDecode(val, dec);
1355
1365
  }
1356
1366
  index = endIdx + 1;
1357
- }
1367
+ } while (index < len);
1358
1368
  return obj;
1359
1369
  }
1360
- function serialize2(name, val, options) {
1361
- var opt = options || {};
1362
- var enc = opt.encode || encode;
1370
+ function startIndex(str, index, max) {
1371
+ do {
1372
+ var code = str.charCodeAt(index);
1373
+ if (code !== 32 && code !== 9) return index;
1374
+ } while (++index < max);
1375
+ return max;
1376
+ }
1377
+ function endIndex(str, index, min) {
1378
+ while (index > min) {
1379
+ var code = str.charCodeAt(--index);
1380
+ if (code !== 32 && code !== 9) return index + 1;
1381
+ }
1382
+ return min;
1383
+ }
1384
+ function serialize2(name, val, opt) {
1385
+ var enc = opt && opt.encode || encodeURIComponent;
1363
1386
  if (typeof enc !== "function") {
1364
1387
  throw new TypeError("option encode is invalid");
1365
1388
  }
1366
- if (!fieldContentRegExp.test(name)) {
1389
+ if (!cookieNameRegExp.test(name)) {
1367
1390
  throw new TypeError("argument name is invalid");
1368
1391
  }
1369
1392
  var value = enc(val);
1370
- if (value && !fieldContentRegExp.test(value)) {
1393
+ if (!cookieValueRegExp.test(value)) {
1371
1394
  throw new TypeError("argument val is invalid");
1372
1395
  }
1373
1396
  var str = name + "=" + value;
1397
+ if (!opt) return str;
1374
1398
  if (null != opt.maxAge) {
1375
- var maxAge = opt.maxAge - 0;
1376
- if (isNaN(maxAge) || !isFinite(maxAge)) {
1399
+ var maxAge = Math.floor(opt.maxAge);
1400
+ if (!isFinite(maxAge)) {
1377
1401
  throw new TypeError("option maxAge is invalid");
1378
1402
  }
1379
- str += "; Max-Age=" + Math.floor(maxAge);
1403
+ str += "; Max-Age=" + maxAge;
1380
1404
  }
1381
1405
  if (opt.domain) {
1382
- if (!fieldContentRegExp.test(opt.domain)) {
1406
+ if (!domainValueRegExp.test(opt.domain)) {
1383
1407
  throw new TypeError("option domain is invalid");
1384
1408
  }
1385
1409
  str += "; Domain=" + opt.domain;
1386
1410
  }
1387
1411
  if (opt.path) {
1388
- if (!fieldContentRegExp.test(opt.path)) {
1412
+ if (!pathValueRegExp.test(opt.path)) {
1389
1413
  throw new TypeError("option path is invalid");
1390
1414
  }
1391
1415
  str += "; Path=" + opt.path;
@@ -1446,11 +1470,8 @@ var require_cookie = __commonJS({
1446
1470
  function decode(str) {
1447
1471
  return str.indexOf("%") !== -1 ? decodeURIComponent(str) : str;
1448
1472
  }
1449
- function encode(val) {
1450
- return encodeURIComponent(val);
1451
- }
1452
1473
  function isDate(val) {
1453
- return __toString.call(val) === "[object Date]" || val instanceof Date;
1474
+ return __toString.call(val) === "[object Date]";
1454
1475
  }
1455
1476
  function tryDecode(str, decode2) {
1456
1477
  try {