mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-20 09:19:54 +03:00
Updated CreateShortCodeContentNegotiationMiddleware so that query parameter takes precedence over Accept header
This commit is contained in:
parent
7c6da4985d
commit
b0dbb2dae4
2 changed files with 5 additions and 3 deletions
|
@ -30,9 +30,10 @@ class CreateShortCodeContentNegotiationMiddleware implements MiddlewareInterface
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
$acceptedType = $request->hasHeader('Accept')
|
$query = $request->getQueryParams();
|
||||||
? $this->determineAcceptTypeFromHeader($request->getHeaderLine('Accept'))
|
$acceptedType = isset($query['format'])
|
||||||
: $this->determineAcceptTypeFromQuery($request->getQueryParams());
|
? $this->determineAcceptTypeFromQuery($query)
|
||||||
|
: $this->determineAcceptTypeFromHeader($request->getHeaderLine('Accept'));
|
||||||
|
|
||||||
// If JSON was requested, return the response from next handler as is
|
// If JSON was requested, return the response from next handler as is
|
||||||
if ($acceptedType === self::JSON) {
|
if ($acceptedType === self::JSON) {
|
||||||
|
|
|
@ -74,6 +74,7 @@ class CreateShortCodeContentNegotiationMiddlewareTest extends TestCase
|
||||||
['application/json', [], 'application/json'],
|
['application/json', [], 'application/json'],
|
||||||
['application/xml', [], 'application/json'],
|
['application/xml', [], 'application/json'],
|
||||||
['text/plain', [], 'text/plain'],
|
['text/plain', [], 'text/plain'],
|
||||||
|
['application/json', ['format' => 'txt'], 'text/plain'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue