@daeryun/dr_components 1.2.82 → 1.2.83
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/lib/utils.js +7 -2
- package/dist/lib/utils.ts +7 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/lib/utils.js
CHANGED
|
@@ -432,14 +432,19 @@ export const setCookie = ({ key, value, days = 0.03 }) => {
|
|
|
432
432
|
return '';
|
|
433
433
|
const expires = new Date();
|
|
434
434
|
expires.setTime(expires.getTime() + days * 24 * 60 * 60 * 1000);
|
|
435
|
-
document.cookie = `${key}=${value};expires=${expires.toUTCString()};path=/`;
|
|
435
|
+
document.cookie = `${key}=${encodeURIComponent(value)};expires=${expires.toUTCString()};path=/`;
|
|
436
436
|
};
|
|
437
437
|
export const getCookie = (key) => {
|
|
438
438
|
if (typeof document === 'undefined')
|
|
439
439
|
return '';
|
|
440
440
|
const cookies = document.cookie.split(';');
|
|
441
441
|
for (const cookie of cookies) {
|
|
442
|
-
const
|
|
442
|
+
const trimmed = cookie.trim();
|
|
443
|
+
const eqIndex = trimmed.indexOf('=');
|
|
444
|
+
if (eqIndex === -1)
|
|
445
|
+
continue;
|
|
446
|
+
const k = trimmed.slice(0, eqIndex);
|
|
447
|
+
const v = trimmed.slice(eqIndex + 1);
|
|
443
448
|
if (k === key) {
|
|
444
449
|
return v;
|
|
445
450
|
}
|
package/dist/lib/utils.ts
CHANGED
|
@@ -479,7 +479,7 @@ export const setCookie = ({ key, value, days = 0.03 }: { key: string; value: str
|
|
|
479
479
|
|
|
480
480
|
const expires = new Date();
|
|
481
481
|
expires.setTime(expires.getTime() + days * 24 * 60 * 60 * 1000);
|
|
482
|
-
document.cookie = `${key}=${value};expires=${expires.toUTCString()};path=/`;
|
|
482
|
+
document.cookie = `${key}=${encodeURIComponent(value)};expires=${expires.toUTCString()};path=/`;
|
|
483
483
|
};
|
|
484
484
|
|
|
485
485
|
export const getCookie = (key: string) => {
|
|
@@ -487,7 +487,12 @@ export const getCookie = (key: string) => {
|
|
|
487
487
|
|
|
488
488
|
const cookies = document.cookie.split(';');
|
|
489
489
|
for (const cookie of cookies) {
|
|
490
|
-
const
|
|
490
|
+
const trimmed = cookie.trim();
|
|
491
|
+
const eqIndex = trimmed.indexOf('=');
|
|
492
|
+
if (eqIndex === -1) continue;
|
|
493
|
+
|
|
494
|
+
const k = trimmed.slice(0, eqIndex);
|
|
495
|
+
const v = trimmed.slice(eqIndex + 1);
|
|
491
496
|
if (k === key) {
|
|
492
497
|
return v;
|
|
493
498
|
}
|