Skip to content

Commit 35cf186

Browse files
authored
Create normalizedHeaders as object with Object prototype. (#12054)
Co-authored-by: phryneas <phryneas@users.noreply.github.com>
1 parent aee0f4f commit 35cf186

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

.changeset/polite-toys-battle.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@apollo/client": patch
3+
---
4+
5+
Fixed a bug where incorrect object access in some Safari extensions could cause a crash.

.size-limits.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"dist/apollo-client.min.cjs": 40252,
3-
"import { ApolloClient, InMemoryCache, HttpLink } from \"dist/index.js\" (production)": 33066
2+
"dist/apollo-client.min.cjs": 40251,
3+
"import { ApolloClient, InMemoryCache, HttpLink } from \"dist/index.js\" (production)": 33061
44
}

src/link/http/selectHttpOptionsAndBody.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ function removeDuplicateHeaders(
205205
): typeof headers {
206206
// If we're not preserving the case, just remove duplicates w/ normalization.
207207
if (!preserveHeaderCase) {
208-
const normalizedHeaders = Object.create(null);
208+
const normalizedHeaders: Record<string, string> = {};
209209
Object.keys(Object(headers)).forEach((name) => {
210210
normalizedHeaders[name.toLowerCase()] = headers[name];
211211
});
@@ -216,15 +216,16 @@ function removeDuplicateHeaders(
216216
// preserving the original name.
217217
// This allows for non-http-spec-compliant servers that expect intentionally
218218
// capitalized header names (See #6741).
219-
const headerData = Object.create(null);
219+
const headerData: Record<string, { originalName: string; value: string }> =
220+
{};
220221
Object.keys(Object(headers)).forEach((name) => {
221222
headerData[name.toLowerCase()] = {
222223
originalName: name,
223224
value: headers[name],
224225
};
225226
});
226227

227-
const normalizedHeaders = Object.create(null);
228+
const normalizedHeaders: Record<string, string> = {};
228229
Object.keys(headerData).forEach((name) => {
229230
normalizedHeaders[headerData[name].originalName] = headerData[name].value;
230231
});

0 commit comments

Comments
 (0)