Skip to content

Commit

Permalink
Use "AbsoluteUri" instead of "ToString()" to avoid removing the escap…
Browse files Browse the repository at this point in the history
…ing from query string parameters.
  • Loading branch information
jamestelfer committed May 17, 2011
1 parent 16c9aed commit c59af2e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Mvc.Mailer.Test/ExtensionMethods/UrlHelperExtensionsTest.cs
Expand Up @@ -53,6 +53,12 @@ public void Abs_with_root_should_absolutilze()
Assert.AreEqual("http://example.com:8080/", _urlHelper.Abs("/"));
}

[Test]
public void Abs_with_encoded_params_should_keep_encoding()
{
Assert.AreEqual("http://example.com:8080/?param=encoded%20value", _urlHelper.Abs("/?param=encoded%20value"));
}

[Test]
public void Abs_with_config_should_use_the_base_url_from_the_config()
{
Expand Down
2 changes: 1 addition & 1 deletion Mvc.Mailer/ExtensionMethods/UrlHelperExtensions.cs
Expand Up @@ -26,7 +26,7 @@ public static string Abs(this UrlHelper urlHelper, string relativeOrAbsoluteUrl)
Uri combinedUri;
if (Uri.TryCreate(BaseUrl(urlHelper), relativeOrAbsoluteUrl, out combinedUri))
{
return combinedUri.ToString();
return combinedUri.AbsoluteUri;
}

throw new Exception(string.Format("Could not create absolute url for {0} using baseUri{0}", relativeOrAbsoluteUrl, BaseUrl(urlHelper)));
Expand Down

0 comments on commit c59af2e

Please sign in to comment.