#53 - implicitly convert System.Uri to Flurl.Url
This commit is contained in:
parent
3983493592
commit
fae2680707
@ -290,5 +290,13 @@ namespace Flurl
|
||||
public static implicit operator Url(string url) {
|
||||
return new Url(url);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implicit conversion from System.Uri to Flurl.Url.
|
||||
/// </summary>
|
||||
/// <returns>The string</returns>
|
||||
public static implicit operator Url(Uri uri) {
|
||||
return new Url(uri.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -189,5 +189,11 @@ namespace Flurl.Test.Http
|
||||
CollectionAssert.IsNotEmpty(client4.GetCookies());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void can_use_uri_with_WithUrl() {
|
||||
var uri = new System.Uri("http://www.mysite.com/foo?x=1");
|
||||
var fc = new FlurlClient().WithUrl(uri);
|
||||
Assert.AreEqual(uri.ToString(), fc.Url.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user