#411 Url.Clone
This commit is contained in:
parent
48740b87d3
commit
75df464cde
@ -493,5 +493,15 @@ namespace Flurl.Test
|
||||
var url2 = new Url("http://mysite.com/hello");
|
||||
Assert.IsFalse(url1 == url2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void clone_creates_copy() {
|
||||
var url1 = new Url("http://mysite.com").SetQueryParam("x", 1);
|
||||
var url2 = url1.Clone().AppendPathSegment("foo").SetQueryParam("y", 2);
|
||||
url1.SetQueryParam("z", 3);
|
||||
|
||||
Assert.AreEqual("http://mysite.com?x=1&z=3", url1.ToString());
|
||||
Assert.AreEqual("http://mysite.com/foo?x=1&y=2", url2.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,12 +7,12 @@ using System.Text.RegularExpressions;
|
||||
namespace Flurl
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a URL that can be built fluently
|
||||
/// A mutable object for fluently building URLs.
|
||||
/// </summary>
|
||||
public class Url
|
||||
{
|
||||
/// <summary>
|
||||
/// The full absolute path part of the URL (everthing except the query and fragment).
|
||||
/// The full absolute path part of the URL (everything except the query and fragment).
|
||||
/// </summary>
|
||||
public string Path { get; set; }
|
||||
|
||||
@ -403,6 +403,11 @@ namespace Flurl
|
||||
/// <returns></returns>
|
||||
public override string ToString() => ToString(false);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a copy of this Url.
|
||||
/// </summary>
|
||||
public Url Clone() => new Url(this);
|
||||
|
||||
/// <summary>
|
||||
/// Converts this Url object to its string representation.
|
||||
/// </summary>
|
||||
|
Loading…
x
Reference in New Issue
Block a user