Skip to content

Commit c1c61b2

Browse files
committed
Merge branch 'ihor-sviziev-patch-1'
2 parents c40d3b3 + 9c6e356 commit c1c61b2

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/Elasticsearch/ClientBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ private function extractURIParts(string $host): array
686686

687687
private function prependMissingScheme(string $host): string
688688
{
689-
if (!filter_var($host, FILTER_VALIDATE_URL)) {
689+
if (!preg_match("/^https?:\/\//", $host)) {
690690
$host = 'http://' . $host;
691691
}
692692

tests/Elasticsearch/Tests/ClientTest.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,17 @@ public function testInlineHosts()
312312
$this->assertSame(9200, $host->getPort());
313313
$this->assertSame("https", $host->getTransportSchema());
314314
$this->assertSame("user:pass", $host->getUserPass());
315+
316+
$client = Elasticsearch\ClientBuilder::create()->setHosts(
317+
[
318+
'https://user:pass@the_foo.com:9200'
319+
]
320+
)->build();
321+
$host = $client->transport->getConnection();
322+
$this->assertSame("the_foo.com", $host->getHost());
323+
$this->assertSame(9200, $host->getPort());
324+
$this->assertSame("https", $host->getTransportSchema());
325+
$this->assertSame("user:pass", $host->getUserPass());
315326
}
316327

317328
public function testExtendedHosts()
@@ -417,7 +428,7 @@ public function testExtendedHosts()
417428
// good
418429
}
419430

420-
// Underscore host, questionably legal, but inline method would break
431+
// Underscore host, questionably legal
421432
$client = Elasticsearch\ClientBuilder::create()->setHosts(
422433
[
423434
[

0 commit comments

Comments
 (0)