Skip to content

Commit

Permalink
Merge pull request #1093 from searchspring/cookie-domain-unset
Browse files Browse the repository at this point in the history
Cookie Domain (unset)
  • Loading branch information
korgon authored Jul 3, 2024
2 parents 66000e9 + b5315c1 commit 1804f38
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/snap-preact/src/Snap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ export class Snap {
// query param / cookiev override
if ((urlParams?.params?.query && 'dev' in urlParams.params.query) || !!cookies.get(DEV_COOKIE)) {
if (urlParams?.params.query?.dev == 'false' || urlParams?.params.query?.dev == '0') {
cookies.unset(DEV_COOKIE);
cookies.unset(DEV_COOKIE, cookieDomain);
this.mode = AppMode.production;
} else {
cookies.set(DEV_COOKIE, '1', 'Lax', 0, cookieDomain);
Expand Down Expand Up @@ -491,7 +491,7 @@ export class Snap {
{...props}
name={branchOverride}
onRemoveClick={() => {
cookies.unset(BRANCH_COOKIE);
cookies.unset(BRANCH_COOKIE, cookieDomain);
const urlState = url(window.location.href);
delete urlState?.params.query['branch'];

Expand Down
2 changes: 1 addition & 1 deletion packages/snap-store-mobx/src/Storage/StorageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class StorageStore {
window.localStorage.removeItem(this.key);
break;
case StorageType.cookie:
utils.cookies.unset(this.key);
utils.cookies.unset(this.key, this.cookieDomain);
break;
}
this.state = {};
Expand Down
4 changes: 2 additions & 2 deletions packages/snap-toolbox/src/cookies/cookies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const cookies: Cookies = {
};

interface Cookies {
set: (name: string, val: string, sameSite?: string, expires?: number, domain?: string | undefined) => void;
set: (name: string, val: string, sameSite?: string, expires?: number, domain?: string) => void;
get: (name: string) => string;
unset: (name: string) => void;
unset: (name: string, domain?: string) => void;
}
2 changes: 1 addition & 1 deletion packages/snap-tracker/src/Tracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ export class Tracker {
},
clear: () => {
if (this.cookies.cart.get().length) {
cookies.unset(CART_PRODUCTS);
cookies.unset(CART_PRODUCTS, COOKIE_DOMAIN);
this.sendPreflight();
}
},
Expand Down

0 comments on commit 1804f38

Please sign in to comment.