Skip to content

Commit

Permalink
Merge pull request #2 from pltrm/fix-accessing-array-offset-on-null
Browse files Browse the repository at this point in the history
fixed problems with accessing on array offset and uninitialized strin…
  • Loading branch information
armax15 authored Nov 30, 2022
2 parents 8115bf4 + 8bcbfe9 commit 6e4200a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/ElasticSearch/Transport/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,15 @@ public function setType(?string $type): void
*/
protected function buildUrl($path, array $options = []): string
{
$isAbsolute = (is_array($path) ? $path[0][0] : $path[0]) === '/';
if (is_array($path)) {
$first = (string) ($path[0] ?? '');
$firstChar = $first !== '' ? $first[0] : '';
} else {
$firstChar = $path[0];
}

$isAbsolute = $firstChar === '/';

$url = $isAbsolute || $this->index === null ? '' : "/{$this->index}";

if ($path && is_array($path) && count($path) > 0) {
Expand Down

0 comments on commit 6e4200a

Please sign in to comment.