happy-dom 13.8.6 → 13.10.0

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.

Files changed (49) hide show
  1. package/README.md +11 -107
  2. package/cjs/browser/utilities/BrowserFrameNavigator.cjs +1 -1
  3. package/cjs/browser/utilities/BrowserFrameNavigator.cjs.map +1 -1
  4. package/cjs/fetch/AbortController.cjs.map +1 -1
  5. package/cjs/fetch/AbortController.d.ts +1 -1
  6. package/cjs/fetch/AbortController.d.ts.map +1 -1
  7. package/cjs/fetch/AbortSignal.cjs +16 -6
  8. package/cjs/fetch/AbortSignal.cjs.map +1 -1
  9. package/cjs/fetch/AbortSignal.d.ts +7 -3
  10. package/cjs/fetch/AbortSignal.d.ts.map +1 -1
  11. package/cjs/fetch/Fetch.cjs +1 -1
  12. package/cjs/fetch/Fetch.cjs.map +1 -1
  13. package/cjs/fetch/Headers.cjs +20 -8
  14. package/cjs/fetch/Headers.cjs.map +1 -1
  15. package/cjs/fetch/Headers.d.ts +7 -1
  16. package/cjs/fetch/Headers.d.ts.map +1 -1
  17. package/cjs/fetch/types/IHeaders.d.ts +6 -0
  18. package/cjs/fetch/types/IHeaders.d.ts.map +1 -1
  19. package/cjs/fetch/utilities/FetchRequestHeaderUtility.cjs +1 -1
  20. package/cjs/fetch/utilities/FetchRequestHeaderUtility.cjs.map +1 -1
  21. package/cjs/version.cjs +1 -1
  22. package/lib/browser/utilities/BrowserFrameNavigator.js +1 -1
  23. package/lib/browser/utilities/BrowserFrameNavigator.js.map +1 -1
  24. package/lib/fetch/AbortController.d.ts +1 -1
  25. package/lib/fetch/AbortController.d.ts.map +1 -1
  26. package/lib/fetch/AbortController.js.map +1 -1
  27. package/lib/fetch/AbortSignal.d.ts +7 -3
  28. package/lib/fetch/AbortSignal.d.ts.map +1 -1
  29. package/lib/fetch/AbortSignal.js +16 -6
  30. package/lib/fetch/AbortSignal.js.map +1 -1
  31. package/lib/fetch/Fetch.js +1 -1
  32. package/lib/fetch/Fetch.js.map +1 -1
  33. package/lib/fetch/Headers.d.ts +7 -1
  34. package/lib/fetch/Headers.d.ts.map +1 -1
  35. package/lib/fetch/Headers.js +20 -8
  36. package/lib/fetch/Headers.js.map +1 -1
  37. package/lib/fetch/types/IHeaders.d.ts +6 -0
  38. package/lib/fetch/types/IHeaders.d.ts.map +1 -1
  39. package/lib/fetch/utilities/FetchRequestHeaderUtility.js +1 -1
  40. package/lib/fetch/utilities/FetchRequestHeaderUtility.js.map +1 -1
  41. package/lib/version.js +1 -1
  42. package/package.json +1 -1
  43. package/src/browser/utilities/BrowserFrameNavigator.ts +1 -1
  44. package/src/fetch/AbortController.ts +1 -1
  45. package/src/fetch/AbortSignal.ts +20 -9
  46. package/src/fetch/Fetch.ts +2 -2
  47. package/src/fetch/Headers.ts +22 -9
  48. package/src/fetch/types/IHeaders.ts +7 -0
  49. package/src/fetch/utilities/FetchRequestHeaderUtility.ts +1 -1
@@ -10,7 +10,7 @@ import IHeadersInit from './types/IHeadersInit.js';
10
10
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Headers
11
11
  */
12
12
  export default class Headers implements IHeaders {
13
- public [PropertySymbol.entries]: { [k: string]: { name: string; value: string } } = {};
13
+ public [PropertySymbol.entries]: { [k: string]: { name: string; value: string[] } } = {};
14
14
 
15
15
  /**
16
16
  * Constructor.
@@ -48,11 +48,11 @@ export default class Headers implements IHeaders {
48
48
  public append(name: string, value: string): void {
49
49
  const lowerName = name.toLowerCase();
50
50
  if (this[PropertySymbol.entries][lowerName]) {
51
- this[PropertySymbol.entries][lowerName].value += `, ${value}`;
51
+ this[PropertySymbol.entries][lowerName].value.push(value);
52
52
  } else {
53
53
  this[PropertySymbol.entries][lowerName] = {
54
54
  name,
55
- value
55
+ value: [value]
56
56
  };
57
57
  }
58
58
  }
@@ -73,7 +73,7 @@ export default class Headers implements IHeaders {
73
73
  * @returns Value.
74
74
  */
75
75
  public get(name: string): string | null {
76
- return this[PropertySymbol.entries][name.toLowerCase()]?.value || null;
76
+ return this[PropertySymbol.entries][name.toLowerCase()]?.value.join(', ') ?? null;
77
77
  }
78
78
 
79
79
  /**
@@ -85,10 +85,23 @@ export default class Headers implements IHeaders {
85
85
  public set(name: string, value: string): void {
86
86
  this[PropertySymbol.entries][name.toLowerCase()] = {
87
87
  name,
88
- value
88
+ value: [value]
89
89
  };
90
90
  }
91
91
 
92
+ /**
93
+ * Returns an array containing the values of all Set-Cookie headers associated with a response.
94
+ *
95
+ * @returns An array of strings representing the values of all the different Set-Cookie headers.
96
+ */
97
+ public getSetCookie(): string[] {
98
+ const entry = this[PropertySymbol.entries]['set-cookie'];
99
+ if (!entry) {
100
+ return [];
101
+ }
102
+ return entry.value;
103
+ }
104
+
92
105
  /**
93
106
  * Returns whether an Headers object contains a certain key.
94
107
  *
@@ -106,7 +119,7 @@ export default class Headers implements IHeaders {
106
119
  */
107
120
  public forEach(callback: (name: string, value: string, thisArg: IHeaders) => void): void {
108
121
  for (const header of Object.values(this[PropertySymbol.entries])) {
109
- callback(header.value, header.name, this);
122
+ callback(header.value.join(', '), header.name, this);
110
123
  }
111
124
  }
112
125
 
@@ -128,7 +141,7 @@ export default class Headers implements IHeaders {
128
141
  */
129
142
  public *values(): IterableIterator<string> {
130
143
  for (const header of Object.values(this[PropertySymbol.entries])) {
131
- yield header.value;
144
+ yield header.value.join(', ');
132
145
  }
133
146
  }
134
147
 
@@ -139,7 +152,7 @@ export default class Headers implements IHeaders {
139
152
  */
140
153
  public *entries(): IterableIterator<[string, string]> {
141
154
  for (const header of Object.values(this[PropertySymbol.entries])) {
142
- yield [header.name, header.value];
155
+ yield [header.name, header.value.join(', ')];
143
156
  }
144
157
  }
145
158
 
@@ -150,7 +163,7 @@ export default class Headers implements IHeaders {
150
163
  */
151
164
  public *[Symbol.iterator](): IterableIterator<[string, string]> {
152
165
  for (const header of Object.values(this[PropertySymbol.entries])) {
153
- yield [header.name, header.value];
166
+ yield [header.name, header.value.join(', ')];
154
167
  }
155
168
  }
156
169
  }
@@ -35,6 +35,13 @@ export default interface IHeaders extends Iterable<[string, string]> {
35
35
  */
36
36
  set(name: string, value: string): void;
37
37
 
38
+ /**
39
+ * Returns an array containing the values of all Set-Cookie headers associated with a response.
40
+ *
41
+ * @returns An array of strings representing the values of all the different Set-Cookie headers.
42
+ */
43
+ getSetCookie(): string[];
44
+
38
45
  /**
39
46
  * Returns whether an Headers object contains a certain key.
40
47
  *
@@ -130,7 +130,7 @@ export default class FetchRequestHeaderUtility {
130
130
  const httpRequestHeaders = {};
131
131
 
132
132
  for (const header of Object.values(headers[PropertySymbol.entries])) {
133
- httpRequestHeaders[header.name] = header.value;
133
+ httpRequestHeaders[header.name] = header.value.join(', ');
134
134
  }
135
135
 
136
136
  return httpRequestHeaders;