This is intended to fix #33 as well as stay compatible with the fix for #8.
The AMQP URI specification states that a missing vhost (i.e. no path on the URI) should be treated as not provided, whereas a trailing / should be treated as an empty vhost.
This PR will adjust this behaviour by using the default vhost if not provided, and trimming the / if it is provided (thus making it empty). Previously this was broken as url.path() will always return / (even if it was not provided in the input); in the case it wasn't provided, the vhost was being set to "" due to the previous clean_vhost implementation. This was coincidentally the same as the default, but this shouldn't be relied upon (read on...).
In order to resolve #33, I took the liberty of setting the default vhost to "/" as it's the default for RabbitMQ, which is widely regarded as the most popular AMQP implementation. Having "" as the default is unintuitive (see #33) for RabbitMQ users as you need to supply amqp://host// to connect successfully.
Tests still pass after accounting for the change to the default, so it shouldn't really break anything; anyone still using amqp://host// will still function correctly, as well as anyone specifying the vhost. The only behaviour change is the default vhost, which can technically be seen as a bug anyway :p
This is intended to fix #33 as well as stay compatible with the fix for #8.
The AMQP URI specification states that a missing vhost (i.e. no path on the URI) should be treated as not provided, whereas a trailing
/
should be treated as an empty vhost.This PR will adjust this behaviour by using the default vhost if not provided, and trimming the
/
if it is provided (thus making it empty). Previously this was broken asurl.path()
will always return/
(even if it was not provided in the input); in the case it wasn't provided, the vhost was being set to""
due to the previousclean_vhost
implementation. This was coincidentally the same as the default, but this shouldn't be relied upon (read on...).In order to resolve #33, I took the liberty of setting the default vhost to
"/"
as it's the default for RabbitMQ, which is widely regarded as the most popular AMQP implementation. Having""
as the default is unintuitive (see #33) for RabbitMQ users as you need to supplyamqp://host//
to connect successfully.Tests still pass after accounting for the change to the default, so it shouldn't really break anything; anyone still using
amqp://host//
will still function correctly, as well as anyone specifying the vhost. The only behaviour change is the default vhost, which can technically be seen as a bug anyway :p