feat: add actual user for trpc wss-dev-server (#261)
* feat: add actual user for trpc wss-dev-server #233 * chore: address pull request feedback * fix: deepsource issue
This commit is contained in:
17
packages/common/src/cookie.ts
Normal file
17
packages/common/src/cookie.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
export function parseCookies(cookieString: string) {
|
||||
const list: Record<string, string> = {};
|
||||
const cookieHeader = cookieString;
|
||||
if (!cookieHeader) return list;
|
||||
|
||||
cookieHeader.split(";").forEach(function (cookie) {
|
||||
const items = cookie.split("=");
|
||||
let name = items.shift();
|
||||
name = name?.trim();
|
||||
if (!name) return;
|
||||
const value = items.join("=").trim();
|
||||
if (!value) return;
|
||||
list[name] = decodeURIComponent(value);
|
||||
});
|
||||
|
||||
return list;
|
||||
}
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from "./object";
|
||||
export * from "./string";
|
||||
export * from "./cookie";
|
||||
|
||||
Reference in New Issue
Block a user