File tree Expand file tree Collapse file tree 4 files changed +17
-32
lines changed Expand file tree Collapse file tree 4 files changed +17
-32
lines changed Original file line number Diff line number Diff line change 11'use strict'
22
33const { parseSetCookie } = require ( './parse' )
4- const { stringify, getHeadersList } = require ( './util' )
4+ const { stringify } = require ( './util' )
55const { webidl } = require ( '../fetch/webidl' )
66const { Headers } = require ( '../fetch/headers' )
77
@@ -77,14 +77,13 @@ function getSetCookies (headers) {
7777
7878 webidl . brandCheck ( headers , Headers , { strict : false } )
7979
80- const cookies = getHeadersList ( headers ) . cookies
80+ const cookies = headers . getSetCookie ( )
8181
8282 if ( ! cookies ) {
8383 return [ ]
8484 }
8585
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 ) )
8887}
8988
9089/**
Original file line number Diff line number Diff line change 11'use strict'
22
3- const assert = require ( 'assert' )
4- const { kHeadersList } = require ( '../core/symbols' )
5-
3+ /**
4+ * @param {string } value
5+ * @returns {boolean }
6+ */
67function isCTLExcludingHtab ( value ) {
78 if ( value . length === 0 ) {
89 return false
@@ -263,29 +264,11 @@ function stringify (cookie) {
263264 return out . join ( '; ' )
264265}
265266
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-
287267module . exports = {
288268 isCTLExcludingHtab,
289- stringify,
290- getHeadersList
269+ validateCookieName,
270+ validateCookiePath,
271+ validateCookieValue,
272+ toIMFDate,
273+ stringify
291274}
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ const {
1010 isValidHeaderName,
1111 isValidHeaderValue
1212} = require ( './util' )
13+ const util = require ( 'util' )
1314const { webidl } = require ( './webidl' )
1415const assert = require ( 'assert' )
1516
@@ -563,6 +564,9 @@ Object.defineProperties(Headers.prototype, {
563564 [ Symbol . toStringTag ] : {
564565 value : 'Headers' ,
565566 configurable : true
567+ } ,
568+ [ util . inspect . custom ] : {
569+ enumerable : false
566570 }
567571} )
568572
Original file line number Diff line number Diff line change 77 getSetCookies,
88 setCookie
99} = require ( '../..' )
10- const { getHeadersList } = require ( '../../lib/cookies/util' )
1110
1211/* global Headers */
1312
@@ -41,7 +40,7 @@ test('Using global Headers', (t) => {
4140 'set-cookie' : 'undici=getSetCookies; Secure'
4241 } )
4342
44- const supportsCookies = getHeadersList ( headers ) . cookies
43+ const supportsCookies = headers . getSetCookie ( )
4544
4645 if ( ! supportsCookies ) {
4746 t . same ( getSetCookies ( headers ) , [ ] )
You can’t perform that action at this time.
0 commit comments