Skip to content

Commit 63d6f91

Browse files
committed
review
1 parent d409da2 commit 63d6f91

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

packages/open-next/src/http/util.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,24 @@ export const parseHeaders = (
1212
if (value === undefined) {
1313
continue;
1414
}
15-
// Next can return an Array for the Location header
16-
// We dont want to merge that into a comma-separated string
17-
// See: https://github.com/opennextjs/opennextjs-cloudflare/issues/875#issuecomment-3258248276
18-
if (key.toLowerCase() === "location" && Array.isArray(value)) {
19-
result[key.toLowerCase()] = value[0];
15+
const keyLower = key.toLowerCase();
16+
/**
17+
* Next can return an Array for the Location header
18+
* We dont want to merge that into a comma-separated string
19+
* If they are the same just return one of them
20+
* Otherwise return the last one
21+
* See: https://github.com/opennextjs/opennextjs-cloudflare/issues/875#issuecomment-3258248276
22+
* and https://github.com/opennextjs/opennextjs-aws/pull/977#issuecomment-3261763114
23+
*/
24+
if (keyLower === "location" && Array.isArray(value)) {
25+
if (value[0] === value[1]) {
26+
result[keyLower] = value[0];
27+
} else {
28+
result[keyLower] = value[value.length - 1];
29+
}
2030
continue;
2131
}
22-
result[key.toLowerCase()] = convertHeader(value);
32+
result[keyLower] = convertHeader(value);
2333
}
2434

2535
return result;

0 commit comments

Comments
 (0)