mirror of
https://github.com/documenso/documenso.git
synced 2026-08-23 23:02:22 +10:00
fix: improve unified settings (#3160)
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Read a cookie value from `document.cookie`.
|
||||
*
|
||||
* Client-side counterpart of `extractCookieFromHeaders`. Only works for cookies that
|
||||
* are not `HttpOnly`, such as the preferred team URL cookie.
|
||||
*/
|
||||
export const extractCookieFromDocument = (cookieName: string): string | null => {
|
||||
const cookiePairs = document.cookie.split(';');
|
||||
|
||||
const cookie = cookiePairs.find((pair) => pair.trim().startsWith(`${cookieName}=`));
|
||||
|
||||
if (!cookie) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return cookie.split('=')[1].trim();
|
||||
};
|
||||
Reference in New Issue
Block a user