From 52beb011107a264bec7a40df65a1550abcee352c Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 12 Mar 2019 00:46:39 +1100 Subject: [PATCH] Removes faulty CustomRouteUrlProvider --- .../Routing/CustomRouteUrlProvider.cs | 50 ------------------- src/Umbraco.Web/Runtime/WebInitialComposer.cs | 3 +- src/Umbraco.Web/Umbraco.Web.csproj | 1 - 3 files changed, 1 insertion(+), 53 deletions(-) delete mode 100644 src/Umbraco.Web/Routing/CustomRouteUrlProvider.cs diff --git a/src/Umbraco.Web/Routing/CustomRouteUrlProvider.cs b/src/Umbraco.Web/Routing/CustomRouteUrlProvider.cs deleted file mode 100644 index 0c6998e7e1..0000000000 --- a/src/Umbraco.Web/Routing/CustomRouteUrlProvider.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Collections.Generic; -using Umbraco.Core.Models.PublishedContent; -using Umbraco.Web.Mvc; - -namespace Umbraco.Web.Routing -{ - /// - /// This url provider is used purely to deal with umbraco custom routes that utilize and will return - /// the URL returned from the current PublishedContentRequest.PublishedContent (virtual node) if the request is in fact a virtual route and - /// the id that is being requested matches the id of the current PublishedContentRequest.PublishedContent. - /// - internal class CustomRouteUrlProvider : IUrlProvider - { - /// - /// This will return the URL that is returned by the assigned custom if this is a custom route - /// - public UrlInfo GetUrl(UmbracoContext umbracoContext, IPublishedContent content, UrlProviderMode mode, string culture, Uri current) - { - if (umbracoContext?.PublishedRequest?.PublishedContent == null) return null; - if (umbracoContext.HttpContext?.Request?.RequestContext?.RouteData?.DataTokens == null) return null; - if (umbracoContext.HttpContext.Request.RequestContext.RouteData.DataTokens.ContainsKey(Core.Constants.Web.CustomRouteDataToken) == false) return null; - - - //If we get this far, it means it's a custom route with published content assigned, check if the id being requested for is the same id as the assigned published content - //NOTE: This looks like it might cause an infinite loop because PublishedContentBase.Url calls into UmbracoContext.Current.UrlProvider.GetUrl which calls back into the IUrlProvider pipeline - // but the specific purpose of this is that a developer is using their own IPublishedContent that returns a specific Url and doesn't go back into the UrlProvider pipeline. - // TODO: We could put a try/catch here just in case, else we could do some reflection checking to see if the implementation is PublishedContentBase and the Url property is not overridden. - return UrlInfo.Url( - content.Id == umbracoContext.PublishedRequest.PublishedContent.Id - ? umbracoContext.PublishedRequest.PublishedContent.GetUrl(culture) - : null, - culture); - } - - /// - /// This always returns an empty result because this url provider is used purely to deal with Umbraco custom routes with - /// UmbracoVirtualNodeRouteHandler, we really only care about the normal URL so that RedirectToCurrentUmbracoPage() works - /// with SurfaceControllers - /// - /// - /// - /// - /// - public IEnumerable GetOtherUrls(UmbracoContext umbracoContext, int id, Uri current) - { - yield break; - } - } -} diff --git a/src/Umbraco.Web/Runtime/WebInitialComposer.cs b/src/Umbraco.Web/Runtime/WebInitialComposer.cs index 5f95ab2b8e..f1c8fcc12f 100644 --- a/src/Umbraco.Web/Runtime/WebInitialComposer.cs +++ b/src/Umbraco.Web/Runtime/WebInitialComposer.cs @@ -181,8 +181,7 @@ namespace Umbraco.Web.Runtime composition.WithCollectionBuilder() .Append() - .Append() - .Append(); + .Append(); composition.RegisterUnique(); diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 985532984f..09cc7d856a 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -877,7 +877,6 @@ -