@solid-primitives/storage
Advanced tools
Comparing version 4.0.0 to 4.1.0
@@ -104,3 +104,4 @@ import { isServer, getRequestEvent, isDev } from 'solid-js/web'; | ||
function deserializeCookieOptions(cookie, key) { | ||
return cookie.match(`(^|;)\\s*${key}\\s*=\\s*([^;]+)`)?.pop() ?? null; | ||
const found = cookie.match(`(^|;)\\s*${key}\\s*=\\s*([^;]+)`)?.pop(); | ||
return found != null ? decodeURIComponent(found) : null; | ||
} | ||
@@ -126,3 +127,3 @@ var getRequestHeaders = isServer ? () => getRequestEvent()?.request?.headers || new Headers() : () => new Headers(); | ||
const responseHeaders = getResponseHeaders(); | ||
const currentCookies = responseHeaders?.get("Set-Cookie")?.split(", ")?.filter((cookie) => cookie && !cookie.startsWith(`${key}=`)) ?? []; | ||
const currentCookies = responseHeaders.get("Set-Cookie")?.split(", ").filter((cookie) => cookie && !cookie.startsWith(`${key}=`)) ?? []; | ||
responseHeaders.set( | ||
@@ -137,6 +138,13 @@ "Set-Cookie", | ||
setItem: (key, value, options) => { | ||
cookieStorage._write(key, value, options); | ||
cookieStorage._write( | ||
key, | ||
value.replace(/[\u00c0-\uffff\&;]/g, (c) => encodeURIComponent(c)), | ||
options | ||
); | ||
}, | ||
removeItem: (key, options) => { | ||
cookieStorage._write(key, "deleted", { ...options, expires: /* @__PURE__ */ new Date(0) }); | ||
cookieStorage._write(key, "deleted", { | ||
...options, | ||
expires: /* @__PURE__ */ new Date(0) | ||
}); | ||
}, | ||
@@ -143,0 +151,0 @@ key: (index, options) => { |
{ | ||
"name": "@solid-primitives/storage", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"description": "Primitive that provides reactive wrappers for storage access", | ||
@@ -5,0 +5,0 @@ "author": "Alex Lohr <alex.lohr@logmein.com>", |
@@ -102,2 +102,6 @@ <p> | ||
> HTTP headers are limited to 32kb, each header itself is limited to 16kb. So depending on your current headers, the space in `cookieStorage` is rather small. If the overall space is exceeded, subsequent requests will fail. We have no mechanism to prevent that, since we cannot infer all headers that the browser will set. | ||
> Browsers do not support most UTF8 and UTF16 characters in Cookies, so `cookieStorage` encodes those characters that are not supported using `encodeURIComponent`. To save space, only those characters not supported by all Browsers will be encoded. | ||
#### LocalForage | ||
@@ -104,0 +108,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
52083
764
284
0