Skip to content

Commit

Permalink
fix : Disable hideDefault with JSON request
Browse files Browse the repository at this point in the history
Disable hideDefault with $request->expectsJson().
  • Loading branch information
MoamenEltouny committed Aug 17, 2021
1 parent 783cbc3 commit 0a4b012
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Classes/Localization.php
Expand Up @@ -205,8 +205,12 @@ private function sub_directory(Request $request, callable $routes)
// IF Supported or not
if ($this->isSupportedLocale($locale)) {
if ($locale == $this->default && $this->hideDefault) {
unset($uriArray[0]);
return Redirect::to(($prefix ? $prefix . '/' : null) . implode('/', $uriArray))->send();
if ($request->expectsJson()) {
return '/{locale?}';
} else {
unset($uriArray[0]);
return Redirect::to(($prefix ? $prefix . '/' : null) . implode('/', $uriArray))->send();
}
} else {
$this->setLocale($locale);

Expand Down

0 comments on commit 0a4b012

Please sign in to comment.