File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ export const parseHeaders = (
2323 * and https://github.com/opennextjs/opennextjs-aws/pull/977#issuecomment-3261763114
2424 */
2525 if ( keyLower === "location" && Array . isArray ( value ) ) {
26- if ( value [ 0 ] === value [ 1 ] ) {
26+ if ( value . length === 1 || value [ 0 ] === value [ 1 ] ) {
2727 result [ keyLower ] = value [ 0 ] ;
2828 } else {
2929 logger . warn (
Original file line number Diff line number Diff line change @@ -65,4 +65,20 @@ describe("parseHeaders", () => {
6565 "x-opennext" : "is-so-cool" ,
6666 } ) ;
6767 } ) ;
68+
69+ it ( "handles location header array with a single value" , ( ) => {
70+ const headers = parseHeaders ( {
71+ location : [ "/target" ] ,
72+ "x-custom-header" : "customValue" ,
73+ "x-multiple-values" : [ "value1" , "value2" ] ,
74+ "x-undefined-header" : undefined ,
75+ "x-opennext" : "is-so-cool" ,
76+ } as unknown as http . OutgoingHttpHeaders ) ;
77+ expect ( headers ) . toEqual ( {
78+ location : "/target" ,
79+ "x-custom-header" : "customValue" ,
80+ "x-multiple-values" : "value1,value2" ,
81+ "x-opennext" : "is-so-cool" ,
82+ } ) ;
83+ } ) ;
6884} ) ;
You can’t perform that action at this time.
0 commit comments