Skip to content

Commit

Permalink
Ensure Path is being serialized
Browse files Browse the repository at this point in the history
  • Loading branch information
HuiSF committed Jun 18, 2024
1 parent af078e7 commit 08d2b44
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ describe('createCookieStorageAdapterFromNextServerContext', () => {
sameSite: 'strict' as any,
httpOnly: true,
secure: true,
path: '/a-path',
};

const result = createCookieStorageAdapterFromNextServerContext(mockContext);
Expand Down Expand Up @@ -176,7 +177,7 @@ describe('createCookieStorageAdapterFromNextServerContext', () => {
mockSerializeOptions.domain
};Expires=${mockSerializeOptions.expires.toUTCString()};HttpOnly;SameSite=${
mockSerializeOptions.sameSite
};Secure`,
};Secure;Path=${mockSerializeOptions.path}`,
);
});

Expand All @@ -188,7 +189,7 @@ describe('createCookieStorageAdapterFromNextServerContext', () => {
mockSerializeOptions.domain
};Expires=${mockSerializeOptions.expires.toUTCString()};HttpOnly;SameSite=${
mockSerializeOptions.sameSite
};Secure`,
};Secure;Path=${mockSerializeOptions.path}`,
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ const createMutableCookieStoreFromHeaders = (
const serializeSetCookieOptions = (
options: CookieStorage.SetCookieOptions,
): string => {
const { expires, domain, httpOnly, sameSite, secure } = options;
const { expires, domain, httpOnly, sameSite, secure, path } = options;
const serializedOptions: string[] = [];
if (domain) {
serializedOptions.push(`Domain=${domain}`);
Expand All @@ -235,6 +235,9 @@ const serializeSetCookieOptions = (
if (secure) {
serializedOptions.push(`Secure`);
}
if (path) {
serializedOptions.push(`Path=${path}`);
}

return serializedOptions.join(';');
};
Expand Down

0 comments on commit 08d2b44

Please sign in to comment.