Skip to content

Commit

Permalink
fix: minor corrections in headers_to_exclude
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
  • Loading branch information
andrey18106 committed Aug 2, 2024
1 parent 9d24476 commit 452cdb4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/Controller/ExAppProxyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,17 @@ private function buildHeadersWithExclude(ExApp $exApp, string $exAppRoute, array
$matchesUrlPattern = preg_match('/' . $route['url'] . '/i', $exAppRoute) === 1;
$matchesVerb = str_contains(strtolower($route['verb']), strtolower($this->request->getMethod()));
if ($matchesUrlPattern && $matchesVerb) {
$headersToExclude = json_decode($route['headers_to_exclude'], true);
$headersToExclude = array_map(function ($headerName) {
return strtolower($headerName);
}, json_decode($route['headers_to_exclude'], true));
break;
}
}
if (empty($headersToExclude)) {
return $headers;
}
foreach ($headers as $key => $value) {
if (in_array($key, $headersToExclude)) {
if (in_array(strtolower($key), $headersToExclude)) {
unset($headers[$key]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Db/ExAppMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public function registerExAppRoutes(ExApp $exApp, array $routes): int {
'url' => $qb->createNamedParameter($route['url']),
'verb' => $qb->createNamedParameter($route['verb']),
'access_level' => $qb->createNamedParameter($route['access_level']),
'headers_to_exclude' => $qb->createNamedParameter($route['headers_to_exclude']),
'headers_to_exclude' => $qb->createNamedParameter(is_array($route['headers_to_exclude']) ? json_encode($route['headers_to_exclude']) : $route['headers_to_exclude']),
]);
$count += $qb->executeStatement();
}
Expand Down

0 comments on commit 452cdb4

Please sign in to comment.