mycouch
mycouch copied to clipboard
Weird DbConnectionInfo Escaping Issue
I have the following problem.
I have a .NET 4.7.2 Windows Application that connects to a couchdb.
Every customer has his own database(s) named like client/customername/dbname
Since the DbName has /
as a special char in urls I have to escape it to use it in rest queries, so the dbname is client%2Fcustomername%2Fdbname
For MyCouch I use the following code which works.
var couchDbName= Uri.EscapeDataString(client/customername/dbname);
var clientConnectionInfo = new DbConnectionInfo(couchDbUrl, couchDbName);
Now, for some reason this won't work for some customers. I tracked down the source of the issue and some instance want to connect to https://domain.tld/client/customername/dbname
instead of https://domain.tld/client%2Fcustomername%2Fdbname
as it should be.
If I investigate the properties of clientConnectionInfo
I can see that clientConnectionInfo.Address
is https://domain.tld/client/customername/dbname
which is wrong.
The stripped down code from ConnectionInfo.cs that is executed is the following.
var serverAddress = new Uri(couchDbUrl);
var parts = new string[] { serverAddress.OriginalString, couchDbName };
var address = new Uri(string.Join("/", parts.Select(p => p.Trim(' ', '/'))));
address = new Uri(address.GetComponents(
UriComponents.AbsoluteUri & ~UriComponents.UserInfo, UriFormat.UriEscaped));
I can't reproduce the issue on my dev machine (windows 10, latest updates) and this happens on a client machine with windows 10 and latest updates, too. I tried the latests version and version 6.0.0 from nuget.
I know this is weired, but I suppose there is something wrong in the frameworks Uri class itself, that unescapes the url, that may have been fixed in a hotfix, that is not applied on the client machine.
Is there anything someone else experienced?