NucuCar.Domain: Fix multiple = bug in ConnectionStringParser
This commit is contained in:
parent
2f6a97cf86
commit
1130464544
2 changed files with 12 additions and 2 deletions
|
@ -25,8 +25,8 @@ namespace NucuCar.Domain.Utilities
|
||||||
var parsedConnectionString = new Dictionary<string, string>();
|
var parsedConnectionString = new Dictionary<string, string>();
|
||||||
foreach (var item in items)
|
foreach (var item in items)
|
||||||
{
|
{
|
||||||
var keyValue = item.Split("=");
|
var keyValue = item.Split("=", 2);
|
||||||
if (keyValue.Length != 2)
|
if (keyValue.Length < 2)
|
||||||
{
|
{
|
||||||
throw new ArgumentException(
|
throw new ArgumentException(
|
||||||
$"Invalid argument for connection string, expected KEY=VALUE got {item}");
|
$"Invalid argument for connection string, expected KEY=VALUE got {item}");
|
||||||
|
|
|
@ -46,6 +46,16 @@ namespace NucuCar.UnitTests.NucuCar.Domain.Tests.Utilities
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
private void Test_ConnectionStringParser_ValueWithMultipleEquals()
|
||||||
|
{
|
||||||
|
const string connectionString = "Test=1;Test2=base64=";
|
||||||
|
var parsedString = ConnectionStringParser.Parse(connectionString);
|
||||||
|
|
||||||
|
Assert.Equal("1", parsedString.GetValueOrDefault("Test"));
|
||||||
|
Assert.Equal("base64=", parsedString.GetValueOrDefault("Test2"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue