fix(styles): persist accent cookies on localhost
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/styles",
|
||||
"version": "0.8.13",
|
||||
"version": "0.8.14",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"exports": {
|
||||
|
||||
@@ -667,7 +667,12 @@ export function renderThemeRuntime(theme: ResolvedTheme): string {
|
||||
options=options||{};
|
||||
var path=options.path||"/";
|
||||
var sameSite=options.sameSite||"Lax";
|
||||
var domain=options.domain?";domain="+options.domain:"";
|
||||
// localhost is not a registrable parent domain. Some browsers reject a
|
||||
// Domain=localhost cookie entirely, so keep it host-only in local dev.
|
||||
var configuredDomain=options.domain;
|
||||
var domain=configuredDomain&&configuredDomain!=="localhost"
|
||||
?";domain="+configuredDomain
|
||||
:"";
|
||||
var secure=options.secure===true||(options.secure!==false&&location.protocol==="https:")?";secure":"";
|
||||
return ";path="+path+";samesite="+sameSite+domain+secure;
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ describe("theme accents", () => {
|
||||
expect(runtime).toContain('"domain":"localhost"');
|
||||
expect(runtime).toContain("deleteCookie(ACCENT_COOKIE);");
|
||||
expect(runtime).toContain("writeCookie(ACCENT_COOKIE,name,ACCENT_COOKIE_OPTIONS)");
|
||||
expect(runtime).toContain('configuredDomain!=="localhost"');
|
||||
expect(runtime).not.toContain("setInterval(syncSharedAccent");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user