mirror of
https://github.com/getgrav/grav.git
synced 2025-02-20 19:56:53 +01:00
Improved redirects: send redirect response in JSON if the request was in JSON
This commit is contained in:
parent
061ebf06c6
commit
956ed013cf
|
|
@ -10,6 +10,7 @@
|
|||
* Improved page cloning, added method `Page::initialize()`
|
||||
* Improved `FlexObject::getChanges()`: return changed lists and arrays as whole instead of just changed keys/values
|
||||
* Improved form validation JSON responses to contain list of failed fields with their error messages
|
||||
* Improved redirects: send redirect response in JSON if the request was in JSON
|
||||
3. [](#bugfix)
|
||||
* Fixed path traversal vulnerability when using `bin/grav server`
|
||||
* Fixed unescaped error messages in JSON error responses
|
||||
|
|
|
|||
|
|
@ -464,6 +464,10 @@ class Grav extends Container
|
|||
}
|
||||
}
|
||||
|
||||
if ($uri->extension() === 'json') {
|
||||
return new Response(200, ['Content-Type' => 'application/json'], json_encode(['code' => $code, 'redirect' => $url], JSON_THROW_ON_ERROR));
|
||||
}
|
||||
|
||||
return new Response($code, ['Location' => $url]);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user