@@ -111,6 +111,57 @@ function parsePriority(string) {
111
111
string = string . toLowerCase ( ) ;
112
112
return PRIORITY . includes ( string ) ? string : void 0 ;
113
113
}
114
+ function splitCookiesString ( cookiesString ) {
115
+ if ( ! cookiesString )
116
+ return [ ] ;
117
+ var cookiesStrings = [ ] ;
118
+ var pos = 0 ;
119
+ var start ;
120
+ var ch ;
121
+ var lastComma ;
122
+ var nextStart ;
123
+ var cookiesSeparatorFound ;
124
+ function skipWhitespace ( ) {
125
+ while ( pos < cookiesString . length && / \s / . test ( cookiesString . charAt ( pos ) ) ) {
126
+ pos += 1 ;
127
+ }
128
+ return pos < cookiesString . length ;
129
+ }
130
+ function notSpecialChar ( ) {
131
+ ch = cookiesString . charAt ( pos ) ;
132
+ return ch !== "=" && ch !== ";" && ch !== "," ;
133
+ }
134
+ while ( pos < cookiesString . length ) {
135
+ start = pos ;
136
+ cookiesSeparatorFound = false ;
137
+ while ( skipWhitespace ( ) ) {
138
+ ch = cookiesString . charAt ( pos ) ;
139
+ if ( ch === "," ) {
140
+ lastComma = pos ;
141
+ pos += 1 ;
142
+ skipWhitespace ( ) ;
143
+ nextStart = pos ;
144
+ while ( pos < cookiesString . length && notSpecialChar ( ) ) {
145
+ pos += 1 ;
146
+ }
147
+ if ( pos < cookiesString . length && cookiesString . charAt ( pos ) === "=" ) {
148
+ cookiesSeparatorFound = true ;
149
+ pos = nextStart ;
150
+ cookiesStrings . push ( cookiesString . substring ( start , lastComma ) ) ;
151
+ start = pos ;
152
+ } else {
153
+ pos = lastComma + 1 ;
154
+ }
155
+ } else {
156
+ pos += 1 ;
157
+ }
158
+ }
159
+ if ( ! cookiesSeparatorFound || pos >= cookiesString . length ) {
160
+ cookiesStrings . push ( cookiesString . substring ( start , cookiesString . length ) ) ;
161
+ }
162
+ }
163
+ return cookiesStrings ;
164
+ }
114
165
115
166
// src/request-cookies.ts
116
167
var RequestCookies = class {
@@ -196,8 +247,10 @@ var ResponseCookies = class {
196
247
constructor ( responseHeaders ) {
197
248
/** @internal */
198
249
this . _parsed = /* @__PURE__ */ new Map ( ) ;
250
+ var _a , _b , _c ;
199
251
this . _headers = responseHeaders ;
200
- const cookieStrings = responseHeaders . getSetCookie ( ) ;
252
+ const setCookie = ( _c = ( _b = ( _a = responseHeaders . getSetCookie ) == null ? void 0 : _a . call ( responseHeaders ) ) != null ? _b : responseHeaders . get ( "set-cookie" ) ) != null ? _c : [ ] ;
253
+ const cookieStrings = Array . isArray ( setCookie ) ? setCookie : splitCookiesString ( setCookie ) ;
201
254
for ( const cookieString of cookieStrings ) {
202
255
const parsed = parseSetCookie ( cookieString ) ;
203
256
if ( parsed )
0 commit comments