happy-dom 9.1.9 → 9.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of happy-dom might be problematic. Click here for more details.

@@ -558,7 +558,7 @@ export default class XMLHttpRequest extends XMLHttpRequestEventTarget {
558
558
  accept: '*/*',
559
559
  referer: location.href,
560
560
  'user-agent': navigator.userAgent,
561
- cookie: document.cookie
561
+ cookie: document._cookie.getCookieString(location, false)
562
562
  };
563
563
  }
564
564
 
@@ -973,13 +973,17 @@ export default class XMLHttpRequest extends XMLHttpRequestEventTarget {
973
973
  * @param headers String array.
974
974
  */
975
975
  private _setCookies(headers: string[] | HTTP.IncomingHttpHeaders): void {
976
+ const originURL = new URL(this._settings.url, this._ownerDocument.defaultView.location);
976
977
  for (const header of ['set-cookie', 'set-cookie2']) {
977
978
  if (Array.isArray(headers[header])) {
978
979
  for (const cookie of headers[header]) {
979
- this._ownerDocument.defaultView.document._cookie.setCookiesString(cookie);
980
+ this._ownerDocument.defaultView.document._cookie.addCookieString(originURL, cookie);
980
981
  }
981
982
  } else if (headers[header]) {
982
- this._ownerDocument.defaultView.document._cookie.setCookiesString(headers[header]);
983
+ this._ownerDocument.defaultView.document._cookie.addCookieString(
984
+ originURL,
985
+ headers[header]
986
+ );
983
987
  }
984
988
  }
985
989
  }