Commit fdb513b
feat: export cookie utilities from undici (#742)
Re-export undici's [Cookie
API](https://github.com/nodejs/undici/blob/main/docs/docs/api/Cookies.md)
from urllib.
- Export `getCookies`, `setCookie`, `getSetCookies`, `deleteCookie`,
`parseCookie` functions and `Cookie` type from `src/index.ts`
- Add tests for all five cookie utilities
```ts
import { getCookies, setCookie, getSetCookies, deleteCookie, parseCookie, Headers } from 'urllib';
import type { Cookie } from 'urllib';
const headers = new Headers();
setCookie(headers, { name: 'foo', value: 'bar' });
const cookies = getSetCookies(headers); // [{ name: 'foo', value: 'bar' }]
```
> [!WARNING]
>
> <details>
> <summary>Firewall rules blocked me from connecting to one or more
addresses (expand for details)</summary>
>
> #### I tried to connect to the following addresses, but was blocked by
firewall rules:
>
> - `http://registry.npmjs.org:80/urllib/latest`
> - Triggering command: `/opt/hostedtoolcache/node/24.14.1/x64/bin/node
/opt/hostedtoolcache/node/24.14.1/x64/bin/node
--experimental-import-meta-resolve --require
/home/REDACTED/work/urllib/urllib/node_modules/.pnpm/@voidzero-dev+[email protected]_@arethetypeswrong+[email protected]_@types+[email protected]__7c6ae394869a5d43fd0cf7dc1d33dc1c/node_modules/@voidzero-dev/vite-plus-test/suppress-warnings.cjs
--conditions node --conditions development
/home/REDACTED/work/urllib/urllib/node_modules/.pnpm/@voidzero-dev+[email protected]_@arethetypeswrong+[email protected]_@types+[email protected]__7c6ae394869a5d43fd0cf7dc1d33dc1c/node_modules/@voidzero-dev/vite-plus-test/dist/workers/forks.js`
(http block)
>
> If you need me to access, download, or install something from one of
these locations, you can either:
>
> - Configure [Actions setup
steps](https://gh.io/copilot/actions-setup-steps) to set up my
environment, which run before the firewall is enabled
> - Add the appropriate URLs or hosts to the custom allowlist in this
repository's [Copilot coding agent
settings](https://github.com/node-modules/urllib/settings/copilot/coding_agent)
(admins only)
>
> </details>
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: fengmk2 <[email protected]>1 parent 7ebec2d commit fdb513b
2 files changed
Lines changed: 64 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
101 | 106 | | |
102 | | - | |
| 107 | + | |
103 | 108 | | |
104 | 109 | | |
105 | 110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
13 | 19 | | |
| 20 | + | |
14 | 21 | | |
15 | 22 | | |
16 | 23 | | |
| |||
423 | 430 | | |
424 | 431 | | |
425 | 432 | | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
426 | 484 | | |
0 commit comments