#582 url-encoding bug with dates

This commit is contained in:
Todd 2020-12-10 17:10:47 -06:00
parent 1185099d77
commit edcf60a62c
2 changed files with 8 additions and 1 deletions

View File

@ -302,6 +302,13 @@ namespace Flurl.Test.UrlBuilder
Assert.AreEqual("http://www.mysite.com?x=%2450&y=2%2B2%3D4", url.ToString()); Assert.AreEqual("http://www.mysite.com?x=%2450&y=2%2B2%3D4", url.ToString());
} }
[Test] // #582
public void encodes_date_type_query_param() {
var date = new DateTime(2020, 12, 6, 10, 45, 1);
var url = "http://www.mysite.com".SetQueryParam("date", date);
Assert.AreEqual("http://www.mysite.com?date=2020-12-06T10%3A45%3A01.0000000", url.ToString());
}
[Test] [Test]
public void does_not_reencode_encoded_query_values() { public void does_not_reencode_encoded_query_values() {
var url = "http://www.mysite.com".SetQueryParam("x", "%CD%EE%E2%FB%E9%20%E3%EE%E4", true); var url = "http://www.mysite.com".SetQueryParam("x", "%CD%EE%E2%FB%E9%20%E3%EE%E4", true);

View File

@ -190,6 +190,6 @@ namespace Flurl
(Value == null) ? null : (Value == null) ? null :
(_encodedValue != null) ? _encodedValue : (_encodedValue != null) ? _encodedValue :
(Value is string s) ? Url.Encode(s, encodeSpaceAsPlus) : (Value is string s) ? Url.Encode(s, encodeSpaceAsPlus) :
Value.ToInvariantString(); Url.Encode(Value.ToInvariantString(), encodeSpaceAsPlus);
} }
} }