Skip to content

Commit 6a869f1

Browse files
authored
[primitives] fix Headers#entries implementation to be consistent (#942)
* update body test * fix entries() function implementation as undici implements it now * refactor test helpers * add changeset * test iterators only if above node.js 16 * run tests against node.js 16.x if they run in edge runtime
1 parent ff65805 commit 6a869f1

File tree

13 files changed

+772
-512
lines changed

13 files changed

+772
-512
lines changed

.changeset/dirty-timers-reply.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
'@edge-runtime/primitives': minor
3+
---
4+
5+
remove custom entries() iterator in favor of Undici's default implementation
6+
7+
The difference will be that `set-cookie` headers will be emitted independently.
8+
9+
```ts
10+
const headers = new Headers()
11+
headers.append('set-cookie', 'a=1')
12+
headers.append('set-cookie', 'b=2')
13+
14+
const entries = [...headers.entries()]
15+
16+
// previous implementation
17+
console.log(entries) // [["set-cookie", "a=1, b=2"]]
18+
19+
// new implementation (undici's native implementation)
20+
console.log(entries) // [["set-cookie", "a=1"], ["set-cookie", "b=2"]]
21+
```

packages/integration-tests/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
},
1010
"license": "MIT",
1111
"devDependencies": {
12-
"http-body": "1.0.12",
1312
"multer": "1.4.5-lts.1",
1413
"test-listen": "1.1.0",
1514
"@types/test-listen": "1.1.2",

packages/integration-tests/test/abort-controller.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1+
import { polyfilledOrNative, guard } from './test-if'
2+
13
if (!globalThis.DOMException) {
24
globalThis.DOMException = require('@edge-runtime/ponyfill').DOMException
35
}
46

5-
const testOrSkip =
6-
process.versions.node.split('.').map(Number)[0] > 16 ? test : test.skip
7-
87
describe('AbortController', () => {
9-
testOrSkip('allows to abort fetch', async () => {
8+
guard(it, polyfilledOrNative)('allows to abort fetch', async () => {
109
expect.assertions(1)
1110
const controller = new AbortController()
1211
controller.abort()

0 commit comments

Comments
 (0)