@@ -111,6 +111,57 @@ function parsePriority(string) {
111111 string = string . toLowerCase ( ) ;
112112 return PRIORITY . includes ( string ) ? string : void 0 ;
113113}
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+ }
114165
115166// src/request-cookies.ts
116167var RequestCookies = class {
@@ -196,8 +247,10 @@ var ResponseCookies = class {
196247 constructor ( responseHeaders ) {
197248 /** @internal */
198249 this . _parsed = /* @__PURE__ */ new Map ( ) ;
250+ var _a , _b , _c ;
199251 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 ) ;
201254 for ( const cookieString of cookieStrings ) {
202255 const parsed = parseSetCookie ( cookieString ) ;
203256 if ( parsed )
0 commit comments