`getCookies()` throws error when cookie header is an empty string
- Dominant language
- TypeScript
- Stars
- 3.6k
- Forks
- 681
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
**Steps to Reproduce**
```ts
import { getCookies } from 'jsr:@std/http@1.1.3/cookie';
const headers = new Headers({ cookie: '' });
getCookies(headers); //fails
```
1. Execute the file using Deno (deno run demo.ts).
2. See error.
**Expected behavior**
`getCookies()` should gracefully handle empty cookie strings and return an empty object {} instead of throwing an exception.
Currently only `null` value is being checked.
https://github.com/denoland/std/blob/ca58f9427152c946ce1c1bc287d290efde1fbab7/http/cookie.ts#L266
**Actual behavior**
```text
error: Uncaught (in promise) SyntaxError: Cookie cannot start with '='
throw new SyntaxError("Cookie cannot start with '='");
```
error thrown at
https://github.com/denoland/std/blob/ca58f9427152c946ce1c1bc287d290efde1fbab7/http/cookie.ts#L271
**Environment**
- OS: Linux
- deno version: 2.9.2
- std version: 1.1.3
Contributor guide
Research direction
Start in http/cookie.ts at the getCookies() implementation and the referenced parsing logic. Reproduce the issue with an empty Cookie header, then verify that getCookies() returns an empty object without throwing while existing cookie behavior remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- deno, typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 85/100