Skip to content

Commit 3c4b24f

Browse files
committed
fix for #789
1 parent 2eefad8 commit 3c4b24f

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

api.include.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11365,7 +11365,7 @@ public function __construct(Config $config)
1136511365

1136611366
private function parseBody(string $body) /*: ?object*/
1136711367
{
11368-
$first = substr($body, 0, 1);
11368+
$first = substr(ltrim($body), 0, 1);
1136911369
if ($first == '[' || $first == '{') {
1137011370
$object = json_decode($body);
1137111371
$causeCode = json_last_error();

api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11365,7 +11365,7 @@ public function __construct(Config $config)
1136511365

1136611366
private function parseBody(string $body) /*: ?object*/
1136711367
{
11368-
$first = substr($body, 0, 1);
11368+
$first = substr(ltrim($body), 0, 1);
1136911369
if ($first == '[' || $first == '{') {
1137011370
$object = json_decode($body);
1137111371
$causeCode = json_last_error();

src/Tqdev/PhpCrudApi/Api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public function __construct(Config $config)
169169

170170
private function parseBody(string $body) /*: ?object*/
171171
{
172-
$first = substr($body, 0, 1);
172+
$first = substr(ltrim($body), 0, 1);
173173
if ($first == '[' || $first == '{') {
174174
$object = json_decode($body);
175175
$causeCode = json_last_error();

tests/functional/001_records/007_edit_post.log

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,25 @@ Content-Type: application/json; charset=utf-8
1616
Content-Length: 62
1717

1818
{"id":3,"user_id":1,"category_id":1,"content":"test (edited)"}
19+
===
20+
PUT /records/posts/3
21+
22+
{
23+
"user_id": 1,
24+
"category_id": 1,
25+
"content": "test (edited 1)"
26+
}
27+
===
28+
200
29+
Content-Type: application/json; charset=utf-8
30+
Content-Length: 1
31+
32+
1
33+
===
34+
GET /records/posts/3
35+
===
36+
200
37+
Content-Type: application/json; charset=utf-8
38+
Content-Length: 64
39+
40+
{"id":3,"user_id":1,"category_id":1,"content":"test (edited 1)"}

0 commit comments

Comments
 (0)