Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #15 from jamestelfer/master

Fix: extension method "Abs" outputs malformed URLs
  • Loading branch information...
commit c1059ffb5b583747b2af86a9f0cdd0c8c2cec8b8 2 parents 16c9aed + c59af2e
@smsohan authored
View
6 Mvc.Mailer.Test/ExtensionMethods/UrlHelperExtensionsTest.cs
@@ -54,6 +54,12 @@ public void Abs_with_root_should_absolutilze()
}
[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()
{
ConfigurationManager.AppSettings[UrlHelperExtensions.BASE_URL_KEY] = "http://my:666";
View
2  Mvc.Mailer/ExtensionMethods/UrlHelperExtensions.cs
@@ -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)));
Please sign in to comment.
Something went wrong with that request. Please try again.