@blotoutio/edgetag-sdk-browser 0.60.1 → 0.61.0

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 (2) hide show
  1. package/index.js +25 -14
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -469,28 +469,39 @@
469
469
  };
470
470
 
471
471
  const getCookieValue = (key) => {
472
+ var _a;
472
473
  try {
473
474
  if (!document || !document.cookie) {
474
475
  return '';
475
476
  }
476
- const name = `${key}=`;
477
- const decodedCookie = decodeURIComponent(document.cookie);
478
- const ca = decodedCookie.split(';');
479
- for (let i = 0; i < ca.length; i++) {
480
- let c = ca[i];
481
- while (c.charAt(0) === ' ') {
482
- c = c.substring(1);
483
- }
484
- if (c.indexOf(name) === 0) {
485
- return c.substring(name.length, c.length);
486
- }
487
- }
488
- return '';
477
+ const cookies = parseCookies(document.cookie);
478
+ return (_a = cookies[key]) !== null && _a !== void 0 ? _a : '';
489
479
  }
490
480
  catch {
491
481
  return '';
492
482
  }
493
483
  };
484
+ const parseCookies = (cookie) => {
485
+ return Object.fromEntries(cookie
486
+ .split(/;\s+/)
487
+ .map((r) => r.split('=').map((str) => str.trim()))
488
+ .map(([cookieKey, cookieValue]) => {
489
+ if (!cookieKey) {
490
+ return [];
491
+ }
492
+ let decodedValue = '';
493
+ if (cookieValue) {
494
+ try {
495
+ decodedValue = decodeURIComponent(cookieValue);
496
+ }
497
+ catch (e) {
498
+ console.log(`Unable to decode cookie ${cookieKey}: ${e}`);
499
+ decodedValue = cookieValue;
500
+ }
501
+ }
502
+ return [cookieKey, decodedValue];
503
+ }));
504
+ };
494
505
 
495
506
  const getUserId$1 = (destination) => {
496
507
  const userId = getSetting(destination, 'userId');
@@ -550,7 +561,7 @@
550
561
  referrer: getReferrer(destination),
551
562
  search: getSearch(destination),
552
563
  locale: getLocale(),
553
- sdkVersion: "0.60.1" ,
564
+ sdkVersion: "0.61.0" ,
554
565
  ...(payload || {}),
555
566
  };
556
567
  let storage = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/edgetag-sdk-browser",
3
- "version": "0.60.1",
3
+ "version": "0.61.0",
4
4
  "description": "Browser SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",