Don't pass in Root to ToAbsolute there's no need
This commit is contained in:
@@ -23,16 +23,14 @@ namespace Umbraco.Core.Hosting
|
||||
/// Maps a virtual path to the application's web root
|
||||
/// </summary>
|
||||
/// <param name="virtualPath">The virtual path. Must start with either ~/ or / else an exception is thrown.</param>
|
||||
/// <param name="root">The absolute web root value. Must start with / else an exception is thrown.</param>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
/// This maps the virtual path syntax to the web root. For example when hosting in a virtual directory called "site" and the value "~/pages/test" is passed in, it will
|
||||
/// map to "/site/pages/test" where "/site" is the value of root.
|
||||
/// map to "/site/pages/test" where "/site" is the value of <see cref="ApplicationVirtualPath"/>.
|
||||
/// </remarks>
|
||||
/// <exception cref="InvalidOperationException">
|
||||
/// If virtualPath does not start with ~/ or /
|
||||
/// If root does not start with /
|
||||
/// </exception>
|
||||
string ToAbsolute(string virtualPath, string root);
|
||||
string ToAbsolute(string virtualPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,8 +56,7 @@ namespace Umbraco.Core.IO
|
||||
public string ResolveUrl(string virtualPath)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(virtualPath)) return virtualPath;
|
||||
// TODO: This is a bit odd, the whole "Root" thing is strange, we're passing this into IHostingEnvironment, but it already should know this value in it's ApplicationVirtualPath
|
||||
return _hostingEnvironment.ToAbsolute(virtualPath, Root);
|
||||
return _hostingEnvironment.ToAbsolute(virtualPath);
|
||||
|
||||
}
|
||||
|
||||
@@ -70,8 +69,7 @@ namespace Umbraco.Core.IO
|
||||
if (Uri.IsWellFormedUriString(virtualPath, UriKind.Absolute))
|
||||
return Attempt.Succeed(virtualPath);
|
||||
|
||||
// TODO: This is a bit odd, the whole "Root" thing is strange, we're passing this into IHostingEnvironment, but it already should know this value in it's ApplicationVirtualPath
|
||||
return Attempt.Succeed(_hostingEnvironment.ToAbsolute(virtualPath, Root));
|
||||
return Attempt.Succeed(_hostingEnvironment.ToAbsolute(virtualPath));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -86,13 +86,12 @@ namespace Umbraco.Web.Common.AspNetCore
|
||||
return Path.Combine(_webHostEnvironment.WebRootPath, newPath);
|
||||
}
|
||||
|
||||
// TODO: Need to take into account 'root' here, maybe not, Root probably shouldn't be a param, see notes in IOHelper that calls this, we already know ApplicationVirtualPath
|
||||
public string ToAbsolute(string virtualPath, string root)
|
||||
public string ToAbsolute(string virtualPath)
|
||||
{
|
||||
if (!virtualPath.StartsWith("~/") && !virtualPath.StartsWith("/"))
|
||||
throw new InvalidOperationException($"{nameof(virtualPath)} must start with ~/ or /");
|
||||
if (!root.StartsWith("/"))
|
||||
throw new InvalidOperationException($"{nameof(virtualPath)} must start with /");
|
||||
|
||||
var root = ApplicationVirtualPath.EnsureStartsWith('/');
|
||||
|
||||
// will occur if it starts with "/"
|
||||
if (Uri.IsWellFormedUriString(virtualPath, UriKind.Absolute))
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Umbraco.Web.Hosting
|
||||
return HostingEnvironment.MapPath(path);
|
||||
}
|
||||
|
||||
public string ToAbsolute(string virtualPath, string root) => VirtualPathUtility.ToAbsolute(virtualPath, root.EnsureStartsWith('/'));
|
||||
public string ToAbsolute(string virtualPath) => VirtualPathUtility.ToAbsolute(virtualPath, ApplicationVirtualPath.EnsureStartsWith('/'));
|
||||
|
||||
|
||||
public string LocalTempPath
|
||||
|
||||
Reference in New Issue
Block a user