amingolmahalle / HttpClientToCurlGenerator

The HttpClientToCurl is a NuGet package for generating curl script of HttpClient in .NET ( C# | CSharp | Dotnet ) supported features: Post, Get, Put, and Delete. content types: application/json, text/xml, application/x-www-form-urlencoded
https://www.nuget.org/packages/HttpClientToCurl
MIT License
51 stars 11 forks source link

Query params not escaped in url, resulting in invalid curl command. #13

Closed m-abs closed 8 months ago

m-abs commented 9 months ago

Hi,

Thanks for the plugin, it was a great for debugging.

Minor problem, query params are not escaped.

Example:

var queryArgs = new Dictionary<string, StringValues>
{  
     { "memberId", "Morten Sjøgren" },
};

var uri = new Uri(QueryHelpers.AddQueryString("http://internal-backend.lan/rest/path", queryArgs));

I'd expect this to become:

curl http://internal-system.lan/rest/path\?memberName=Morten%20Sj%C3%B8gren

But I get this:

curl http://internal-system.lan/rest/path\?memberName=Morten Sjøgren

Which of course doesn't work because of the space and the unescaped danish letter ø.

amingolmahalle commented 9 months ago

Hello dear Morten. I'm happy this extension was useful for you. I'm sorry about this issue. I sure check this problem and I will fix it. Thank you.