Skip to content

Commit c793801

Browse files
committed
Use Umbraco Path instead of constant
1 parent a779803 commit c793801

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

src/Umbraco.Core/Sync/ApplicationUrlHelper.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,25 @@ public static string GetApplicationUrlFromCurrentRequest(HttpRequestBase request
112112
/// <returns></returns>
113113
public static Uri GetApplicationUriUncached(
114114
HttpRequestBase request,
115-
IUmbracoSettingsSection umbracoSettingsSection)
115+
IUmbracoSettingsSection umbracoSettingsSection,
116+
IGlobalSettings globalSettings)
116117
{
117118
var settingUrl = umbracoSettingsSection.WebRouting.UmbracoApplicationUrl;
118-
return string.IsNullOrEmpty(settingUrl)
119-
? new Uri(request.Url, IOHelper.ResolveUrl(SystemDirectories.Umbraco))
120-
: new Uri(settingUrl);
119+
120+
121+
if (string.IsNullOrEmpty(settingUrl))
122+
{
123+
if (!Uri.TryCreate(request.Url, VirtualPathUtility.ToAbsolute(globalSettings.Path), out var result))
124+
{
125+
throw new InvalidOperationException(
126+
$"Could not create an url from {request.Url} and {globalSettings.Path}");
127+
}
128+
return result;
129+
}
130+
else
131+
{
132+
return new Uri(settingUrl);
133+
}
121134
}
122135
}
123136
}

src/Umbraco.Web/Editors/AuthenticationController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ private string ConstructCallbackUrl(int userId, string code)
566566
});
567567

568568
// Construct full URL using configured application URL (which will fall back to current request)
569-
var applicationUri = ApplicationUrlHelper.GetApplicationUriUncached(http.Request, _umbracoSettingsSection);
569+
var applicationUri = ApplicationUrlHelper.GetApplicationUriUncached(http.Request, _umbracoSettingsSection, GlobalSettings);
570570
var callbackUri = new Uri(applicationUri, action);
571571
return callbackUri.ToString();
572572
}

src/Umbraco.Web/Editors/UsersController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ private async Task SendUserInviteEmailAsync(UserBasic userDisplay, string from,
540540
});
541541

542542
// Construct full URL will use the value in settings if specified, otherwise will use the current request URL
543-
var requestUrl = ApplicationUrlHelper.GetApplicationUriUncached(http.Request, _umbracoSettingsSection);
543+
var requestUrl = ApplicationUrlHelper.GetApplicationUriUncached(http.Request, _umbracoSettingsSection, GlobalSettings);
544544
var inviteUri = new Uri(requestUrl, action);
545545

546546
var emailSubject = Services.TextService.Localize("user", "inviteEmailCopySubject",

0 commit comments

Comments
 (0)