Skip to content

Commit 63fd6e1

Browse files
committed
Some cleanup
1 parent b669a37 commit 63fd6e1

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/Bridge/Symfony/Bundle/Test/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function request(string $method, string $url, array $options = []): Respo
7575
(\is_array($options['body']) || $options['body'] instanceof \JsonSerializable) &&
7676
(
7777
$json ||
78-
false !== preg_match('#^application/(?:.+\+)?json#', $options['headers']['content-type'][0])
78+
preg_match('/\bjson\b/i', $options['headers']['content-type'][0])
7979
)
8080
) {
8181
// Encode the JSON

src/Bridge/Symfony/Bundle/Test/Response.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ public function getInfo(string $type = null)
7171
*/
7272
private function checkStatusCode()
7373
{
74+
// TODO: use https://github.com/symfony/symfony/pull/30559 instead
7475
$message = 'An error '.$this->info['http_code'].' occured.';
75-
if (isset($this->headers['content-type'][0]) && false !== preg_match('#^application/(?:.+\+)?json#', $this->headers['content-type'][0])) {
76+
if (isset($this->headers['content-type'][0]) && preg_match('/\bjson\b/i', $this->headers['content-type'][0])) {
7677
if ($json = json_decode($this->content, true)) {
7778
// Try to extract the error message from Hydra or RFC 7807 error structures
7879
$message = $json['hydra:description'] ?? $json['hydra:title'] ?? $json['detail'] ?? $json['title'] ?? $message;

0 commit comments

Comments
 (0)