Skip to content

Commit

Permalink
extracting language from url was bugged
Browse files Browse the repository at this point in the history
  • Loading branch information
saibotd committed Jun 12, 2019
1 parent 8c1b367 commit 5ede4b8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Controller/ContentApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ private function init(Request $request): Request
if (substr($url, 0, 1) != '/') {
$url = "/$url";
}
$urlParts = explode('/', $request->query->get('url'));
$this->lang = count($urlParts) > 0 && strlen($urlParts[0]) == 2 ? $urlParts[0] : null;
$urlParts = explode('/', $url);
$this->lang = count($urlParts) > 1 && strlen($urlParts[1]) == 2 ? $urlParts[1] : null;
}
if (!$this->lang) {
$sitemap = new Sitemap();
Expand Down Expand Up @@ -98,7 +98,7 @@ private function init(Request $request): Request
public function sitemapAction(Request $request)
{
$request = $this->init($request);
$sitemap = new Sitemap($this->lang);
$sitemap = new Sitemap($request->query->get('lang', null));

return new ContentApiResponse($sitemap, 200, $this->headers);
}
Expand All @@ -114,7 +114,7 @@ public function sitemapFlatAction(Request $request)
{
$request = $this->init($request);

return new ContentApiResponse(new SitemapFlat($this->lang), 200, $this->headers);
return new ContentApiResponse(new SitemapFlat($request->query->get('lang', null)), 200, $this->headers);
}

/**
Expand Down

0 comments on commit 5ede4b8

Please sign in to comment.