Skip to content

Commit

Permalink
Tolerate trailing semicolon in RabbitMQ connection string
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-toporet committed May 13, 2024
1 parent 8cf9279 commit bacd099
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,15 @@ public void virtual_host()
ConnectionStringParser.Apply("virtualhost=weird", theFactory);
theFactory.VirtualHost.ShouldBe("weird");
}

[Theory]
[InlineData("host=foo;port=5673;")]
[InlineData("host=foo;port=5673")]
public void trailing_semicolon_is_optional(string connectionString)
{
ConnectionStringParser.Apply(connectionString, theFactory);
theFactory.HostName.ShouldBe("foo");
theFactory.Port.ShouldBe(5673);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ internal static class ConnectionStringParser
{
public static void Apply(string connectionString, ConnectionFactory factory)
{
var values = connectionString.ToDelimitedArray(';');
var values = connectionString.ToDelimitedArray(';').Where(x => x.IsNotEmpty());
foreach (var value in values)
{
var parts = value.ToDelimitedArray('=');
Expand Down

0 comments on commit bacd099

Please sign in to comment.