11<?php
22declare (strict_types=1 );
33
4- /** @version 0.0.6 */
5-
64use Loki \Theme \ViewModel \CookieConfig ;
75use Magento \Framework \View \Element \Template ;
86
7+ /** @version 0.0.6 */
98/** @var Template $block */
109/** @var CookieConfig $cookieConfig */
1110
@@ -25,10 +24,10 @@ $cookieConfig = $block->getCookieConfig();
2524 const name = parts[0].trim();
2625 let value = parts[1].trim();
2726
27+ value = decodeURI(value);
28+ value = decodeURIComponent(value);
2829 if (value.startsWith('{') && value.endsWith('}')) {
2930 value = JSON.parse(value);
30- } else {
31- value = decodeURI(value);
3231 }
3332
3433 cookies[name] = value;
@@ -43,7 +42,10 @@ $cookieConfig = $block->getCookieConfig();
4342 let cookieParts = [];
4443 cookieParts.push(name + '=' + value);
4544 cookieParts.push('max-age=' + this.lifetime + 20000);
46- cookieParts.push('path=' + this.path);
45+
46+ if (this.path) {
47+ cookieParts.push('path=' + this.path);
48+ }
4749
4850 if (this.domain) {
4951 cookieParts.push('domain=' + this.domain);
@@ -54,7 +56,12 @@ $cookieConfig = $block->getCookieConfig();
5456 }
5557
5658 cookieParts.push('SameSite=' + this.sameSite);
59+ console.log('set cookie', cookieParts);
60+
5761 document.cookie = cookieParts.join('; ');
62+ },
63+ isAllowedSaving() {
64+ return this.get('user_allowed_save_cookie');
5865 }
5966 }
6067</script>
0 commit comments