Skip to content

Commit 95aa2fe

Browse files
[11.x] Allow customizing TrimStrings::$except (#50901)
* extract method * formatting --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent 96593e2 commit 95aa2fe

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/Illuminate/Foundation/Http/Middleware/TrimStrings.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,25 @@ protected function transform($key, $value)
6262
{
6363
$except = array_merge($this->except, static::$neverTrim);
6464

65-
if (in_array($key, $except, true) || ! is_string($value)) {
65+
if ($this->shouldSkip($key, $except) || ! is_string($value)) {
6666
return $value;
6767
}
6868

6969
return Str::trim($value);
7070
}
7171

72+
/**
73+
* Determine if the given key should be skipped.
74+
*
75+
* @param string $key
76+
* @param array $except
77+
* @return bool
78+
*/
79+
protected function shouldSkip($key, $except)
80+
{
81+
return in_array($key, $except, true);
82+
}
83+
7284
/**
7385
* Indicate that the given attributes should never be trimmed.
7486
*

0 commit comments

Comments
 (0)