Use Umbraco Path instead of constant

This commit is contained in:
Bjarke Berg
2022-01-27 15:57:22 +01:00
parent a779803763
commit c79380191b
3 changed files with 19 additions and 6 deletions

View File

@@ -112,12 +112,25 @@ namespace Umbraco.Core.Sync
/// <returns></returns>
public static Uri GetApplicationUriUncached(
HttpRequestBase request,
IUmbracoSettingsSection umbracoSettingsSection)
IUmbracoSettingsSection umbracoSettingsSection,
IGlobalSettings globalSettings)
{
var settingUrl = umbracoSettingsSection.WebRouting.UmbracoApplicationUrl;
return string.IsNullOrEmpty(settingUrl)
? new Uri(request.Url, IOHelper.ResolveUrl(SystemDirectories.Umbraco))
: new Uri(settingUrl);
if (string.IsNullOrEmpty(settingUrl))
{
if (!Uri.TryCreate(request.Url, VirtualPathUtility.ToAbsolute(globalSettings.Path), out var result))
{
throw new InvalidOperationException(
$"Could not create an url from {request.Url} and {globalSettings.Path}");
}
return result;
}
else
{
return new Uri(settingUrl);
}
}
}
}

View File

@@ -566,7 +566,7 @@ namespace Umbraco.Web.Editors
});
// Construct full URL using configured application URL (which will fall back to current request)
var applicationUri = ApplicationUrlHelper.GetApplicationUriUncached(http.Request, _umbracoSettingsSection);
var applicationUri = ApplicationUrlHelper.GetApplicationUriUncached(http.Request, _umbracoSettingsSection, GlobalSettings);
var callbackUri = new Uri(applicationUri, action);
return callbackUri.ToString();
}

View File

@@ -540,7 +540,7 @@ namespace Umbraco.Web.Editors
});
// Construct full URL will use the value in settings if specified, otherwise will use the current request URL
var requestUrl = ApplicationUrlHelper.GetApplicationUriUncached(http.Request, _umbracoSettingsSection);
var requestUrl = ApplicationUrlHelper.GetApplicationUriUncached(http.Request, _umbracoSettingsSection, GlobalSettings);
var inviteUri = new Uri(requestUrl, action);
var emailSubject = Services.TextService.Localize("user", "inviteEmailCopySubject",