File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -108,10 +108,17 @@ public static function trimValues(iterable $values):iterable{
108
108
}
109
109
110
110
/**
111
- * Normalizes a header name, e.g. "conTENT - lenGTh" -> "Content-Length"
111
+ * Normalizes a header name, e.g. "con TENT - lenGTh" -> "Content-Length"
112
112
*/
113
113
public static function normalizeHeaderName (string $ name ):string {
114
- return implode ('- ' , array_map (fn (string $ v ):string => ucfirst (strtolower (trim ($ v ))), explode ('- ' , $ name )));
114
+ $ parts = explode ('- ' , $ name );
115
+
116
+ foreach ($ parts as &$ part ){
117
+ // we'll remove any spaces in the name part, e.g. "con tent" -> "content"
118
+ $ part = ucfirst (strtolower (str_replace (' ' , '' , trim ($ part ))));
119
+ }
120
+
121
+ return implode ('- ' , $ parts );
115
122
}
116
123
117
124
}
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ public static function headerDataProvider():array{
35
35
'invalid: what ' => [['what ' ], []],
36
36
'empty value ' => [['empty-value ' => '' ], ['Empty-Value ' => '' ]],
37
37
'null value ' => [['null-value ' => null ], ['Null-Value ' => '' ]],
38
+ 'space in name ' => [['space name - header ' => 'nope ' ], ['Spacename-Header ' => 'nope ' ]],
38
39
];
39
40
}
40
41
You can’t perform that action at this time.
0 commit comments