#603 trim final url

This commit is contained in:
Todd 2021-04-27 16:51:53 -05:00
parent 05d0a311c3
commit e24ff982e6
2 changed files with 9 additions and 4 deletions

View File

@ -604,5 +604,11 @@ namespace Flurl.Test.UrlBuilder
url.AppendPathSegment("///");
Assert.AreEqual("https://www.site.com/a/b/c///", url.ToString());
}
[Test]
public void url_trims_leading_and_trailing_whitespace() {
var url = new Url(" https://www.site.com \t");
Assert.AreEqual("https://www.site.com", url.ToString());
}
}
}

View File

@ -140,10 +140,9 @@ namespace Flurl
/// <summary>
/// Constructs a Url object from a string.
/// </summary>
/// <param name="baseUrl">The URL to use as a starting point (required)</param>
/// <exception cref="ArgumentNullException"><paramref name="baseUrl"/> is <see langword="null" />.</exception>
/// <param name="baseUrl">The URL to use as a starting point.</param>
public Url(string baseUrl = null) {
_originalString = baseUrl;
_originalString = baseUrl?.Trim();
}
/// <summary>
@ -508,7 +507,7 @@ namespace Flurl
QueryParams.Any() ? "?" : "",
QueryParams.ToString(encodeSpaceAsPlus),
Fragment?.Length > 0 ? "#" : "",
Fragment);
Fragment).Trim();
}
/// <summary>