Update ui/litellm-dashboard/src/utils/cookieUtils.ts

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
This commit is contained in:
Hendrik Jaks 2026-03-13 10:22:32 +02:00 • committed by GitHub
parent 04f835ecfa
commit 22409da932
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -64,5 +64,12 @@ export function setTokenCookie(token: string) {
export function getCookie(name: string) {
if (typeof document === "undefined") return null;
const cookieValue = document.cookie.split("; ").find((row) => row.startsWith(name + "="));
return cookieValue ? (() => { try { return decodeURIComponent(cookieValue.split("=")[1]); } catch { return cookieValue.split("=")[1]; } })() : null;
if (!cookieValue) return null;
const rawValue = cookieValue.split("=")[1];
try {
return decodeURIComponent(rawValue);
} catch {
return rawValue;
}
}
}