Skip to content

Commit 14ab754

Browse files
authored
Merge pull request #697 from rpanfili/fix_696
[amqp] fix #696 parsing vhost from amqp dsn
2 parents 8b94d3a + 35aa5cb commit 14ab754

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

Diff for: pkg/amqp-tools/ConnectionConfig.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,9 @@ private function parseDsn($dsn)
402402
'port' => $dsn->getPort(),
403403
'user' => $dsn->getUser(),
404404
'pass' => $dsn->getPassword(),
405-
'vhost' => null !== $dsn->getPath() ? ltrim($dsn->getPath(), '/') : null,
405+
'vhost' => null !== ($path = $dsn->getPath()) ?
406+
(0 === strpos($path, '/') ? substr($path, 1) : $path)
407+
: null,
406408
'read_timeout' => $dsn->getFloat('read_timeout'),
407409
'write_timeout' => $dsn->getFloat('write_timeout'),
408410
'connection_timeout' => $dsn->getFloat('connection_timeout'),

Diff for: pkg/amqp-tools/Tests/ConnectionConfigTest.php

+26
Original file line numberDiff line numberDiff line change
@@ -534,5 +534,31 @@ public static function provideConfigs()
534534
'ssl_passphrase' => '',
535535
],
536536
];
537+
538+
yield [
539+
'amqp://guest:guest@localhost:5672/%2f',
540+
[
541+
'host' => 'localhost',
542+
'port' => 5672,
543+
'vhost' => '/',
544+
'user' => 'guest',
545+
'pass' => 'guest',
546+
'read_timeout' => 3.,
547+
'write_timeout' => 3.,
548+
'connection_timeout' => 3.,
549+
'persisted' => false,
550+
'lazy' => true,
551+
'qos_prefetch_size' => 0,
552+
'qos_prefetch_count' => 1,
553+
'qos_global' => false,
554+
'heartbeat' => 0.0,
555+
'ssl_on' => false,
556+
'ssl_verify' => true,
557+
'ssl_cacert' => '',
558+
'ssl_cert' => '',
559+
'ssl_key' => '',
560+
'ssl_passphrase' => '',
561+
],
562+
];
537563
}
538564
}

0 commit comments

Comments
 (0)