#18630: Fixing image publication on Azure

Work Item: 18630

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2012-04-25 16:00:38 -07:00
parent 74322902ec
commit 12e54a5ab6

View File

@@ -25,6 +25,10 @@ namespace Orchard.Mvc.Extensions {
}
public static string MakeAbsolute(this UrlHelper urlHelper, string url, string baseUrl = null) {
if(url.StartsWith("http", StringComparison.OrdinalIgnoreCase)) {
return url;
}
if(String.IsNullOrEmpty(baseUrl)) {
baseUrl = urlHelper.RequestContext.HttpContext.Request.ToApplicationRootUrlString();
}
@@ -34,14 +38,14 @@ namespace Orchard.Mvc.Extensions {
}
// remove any application path from the base url
var applicationPath = urlHelper.RequestContext.HttpContext.Request.ApplicationPath;
var applicationPath = urlHelper.RequestContext.HttpContext.Request.ApplicationPath ?? String.Empty;
// orchardlocal/foo/bar => /orchardlocal/foo/bar
if(!url.StartsWith("/")) {
url = "/" + url;
}
// /orchardlocal/foo/bar => foo/bar
if (url.StartsWith(applicationPath)) {
if (url.StartsWith(applicationPath, StringComparison.OrdinalIgnoreCase)) {
url = url.Substring(applicationPath.Length);
}