File tree 4 files changed +17
-32
lines changed
4 files changed +17
-32
lines changed Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
3
const { parseSetCookie } = require ( './parse' )
4
- const { stringify, getHeadersList } = require ( './util' )
4
+ const { stringify } = require ( './util' )
5
5
const { webidl } = require ( '../fetch/webidl' )
6
6
const { Headers } = require ( '../fetch/headers' )
7
7
@@ -77,14 +77,13 @@ function getSetCookies (headers) {
77
77
78
78
webidl . brandCheck ( headers , Headers , { strict : false } )
79
79
80
- const cookies = getHeadersList ( headers ) . cookies
80
+ const cookies = headers . getSetCookie ( )
81
81
82
82
if ( ! cookies ) {
83
83
return [ ]
84
84
}
85
85
86
- // In older versions of undici, cookies is a list of name:value.
87
- return cookies . map ( ( pair ) => parseSetCookie ( Array . isArray ( pair ) ? pair [ 1 ] : pair ) )
86
+ return cookies . map ( ( pair ) => parseSetCookie ( pair ) )
88
87
}
89
88
90
89
/**
Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
- const assert = require ( 'assert' )
4
- const { kHeadersList } = require ( '../core/symbols' )
5
-
3
+ /**
4
+ * @param {string } value
5
+ * @returns {boolean }
6
+ */
6
7
function isCTLExcludingHtab ( value ) {
7
8
if ( value . length === 0 ) {
8
9
return false
@@ -263,29 +264,11 @@ function stringify (cookie) {
263
264
return out . join ( '; ' )
264
265
}
265
266
266
- let kHeadersListNode
267
-
268
- function getHeadersList ( headers ) {
269
- if ( headers [ kHeadersList ] ) {
270
- return headers [ kHeadersList ]
271
- }
272
-
273
- if ( ! kHeadersListNode ) {
274
- kHeadersListNode = Object . getOwnPropertySymbols ( headers ) . find (
275
- ( symbol ) => symbol . description === 'headers list'
276
- )
277
-
278
- assert ( kHeadersListNode , 'Headers cannot be parsed' )
279
- }
280
-
281
- const headersList = headers [ kHeadersListNode ]
282
- assert ( headersList )
283
-
284
- return headersList
285
- }
286
-
287
267
module . exports = {
288
268
isCTLExcludingHtab,
289
- stringify,
290
- getHeadersList
269
+ validateCookieName,
270
+ validateCookiePath,
271
+ validateCookieValue,
272
+ toIMFDate,
273
+ stringify
291
274
}
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ const {
10
10
isValidHeaderName,
11
11
isValidHeaderValue
12
12
} = require ( './util' )
13
+ const util = require ( 'util' )
13
14
const { webidl } = require ( './webidl' )
14
15
const assert = require ( 'assert' )
15
16
@@ -563,6 +564,9 @@ Object.defineProperties(Headers.prototype, {
563
564
[ Symbol . toStringTag ] : {
564
565
value : 'Headers' ,
565
566
configurable : true
567
+ } ,
568
+ [ util . inspect . custom ] : {
569
+ enumerable : false
566
570
}
567
571
} )
568
572
Original file line number Diff line number Diff line change 7
7
getSetCookies,
8
8
setCookie
9
9
} = require ( '../..' )
10
- const { getHeadersList } = require ( '../../lib/cookies/util' )
11
10
12
11
/* global Headers */
13
12
@@ -41,7 +40,7 @@ test('Using global Headers', (t) => {
41
40
'set-cookie' : 'undici=getSetCookies; Secure'
42
41
} )
43
42
44
- const supportsCookies = getHeadersList ( headers ) . cookies
43
+ const supportsCookies = headers . getSetCookie ( )
45
44
46
45
if ( ! supportsCookies ) {
47
46
t . same ( getSetCookies ( headers ) , [ ] )
You can’t perform that action at this time.
0 commit comments