Skip to content

Commit 21cfbfe

Browse files
committed
fix: patch up errors with input()
1 parent 76bd521 commit 21cfbfe

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/Request.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,16 @@ public static function input($safeData = true)
105105
$param = explode("=", $chunk);
106106
$data[$param[0]] = $param[1];
107107
}
108+
} else if (Headers::get('Content-Type') !== 'application/json' && strpos(Headers::get('Content-Type'), "multipart/form-data") !== 0) {
109+
$safeData = false;
110+
$data = [$data];
108111
} else {
109112
if (!$data) {
110113
$data = json_encode([]);
111114
}
112115

113116
$parsedData = json_decode($data, true);
114-
if (is_array($parsedData)) {
115-
$data = $parsedData;
116-
}
117+
$data = is_array($parsedData) ? $parsedData : [$parsedData];
117118
}
118119

119120
return $safeData ? \Leaf\Anchor::sanitize($data) : $data;
@@ -238,7 +239,7 @@ public static function get($params, bool $safeData = true)
238239
*/
239240
public static function body(bool $safeData = true)
240241
{
241-
$finalData = array_merge(static::urlData(), $_FILES, static::postData(), static::input($safeData));
242+
$finalData = array_merge(static::urlData(), $_FILES, static::postData(), static::input());
242243

243244
return $safeData ?
244245
\Leaf\Anchor::sanitize($finalData) :

0 commit comments

Comments
 (0)