diff --git a/Models/UrlTrackerDomain.cs b/Models/UrlTrackerDomain.cs index 79b2e1f..7b82a25 100644 --- a/Models/UrlTrackerDomain.cs +++ b/Models/UrlTrackerDomain.cs @@ -28,7 +28,10 @@ public string UrlWithDomain { /*var url = new Node(node.Id).Url; return url;*/ - return Node.Url; // do not re-instantiate + var url = !Node.Url.StartsWith("/") + ? Node.Url + : string.Format("{0}{1}{2}", Uri.UriSchemeHttp, Uri.SchemeDelimiter, HttpContext.Current.Request.Url.Host) + Node.Url; + return url.TrimEnd('/'); // do not re-instantiate } else { diff --git a/Repositories/UrlTrackerRepository.cs b/Repositories/UrlTrackerRepository.cs index ccf426c..983fcf2 100644 --- a/Repositories/UrlTrackerRepository.cs +++ b/Repositories/UrlTrackerRepository.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading; +using System.Web; using InfoCaster.Umbraco.UrlTracker.Extensions; using InfoCaster.Umbraco.UrlTracker.Helpers; using InfoCaster.Umbraco.UrlTracker.Models; @@ -52,7 +53,10 @@ public static bool AddUrlMapping(IContent content, int rootNodeId, string url, A if (UrlTrackerSettings.HasDomainOnChildNode) { var rootNode = new Node(rootNodeId); - var rootUri = new Uri(rootNode.NiceUrl); + var rootUrl = !rootNode.Url.StartsWith("/") + ? rootNode.NiceUrl + : string.Format("{0}{1}{2}", Uri.UriSchemeHttp, Uri.SchemeDelimiter, HttpContext.Current.Request.Url.Host) + rootNode.NiceUrl; + var rootUri = new Uri(rootUrl); var shortRootUrl = UrlTrackerHelper.ResolveShortestUrl(rootUri.AbsolutePath); if (url.StartsWith(shortRootUrl, StringComparison.OrdinalIgnoreCase)) { diff --git a/UrlTrackerApplicationEventHandler.cs b/UrlTrackerApplicationEventHandler.cs index 3adc2c0..284f4d0 100644 --- a/UrlTrackerApplicationEventHandler.cs +++ b/UrlTrackerApplicationEventHandler.cs @@ -3,22 +3,18 @@ using InfoCaster.Umbraco.UrlTracker.Models; using InfoCaster.Umbraco.UrlTracker.Repositories; using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.Linq; using System.Web; using System.Web.UI; using umbraco; -using umbraco.BusinessLogic; using umbraco.cms.businesslogic; using umbraco.cms.businesslogic.web; -using umbraco.DataLayer; using umbraco.NodeFactory; using Umbraco.Core; using Umbraco.Core.Events; using Umbraco.Core.Models; using Umbraco.Core.Publishing; using Umbraco.Core.Services; +using Umbraco.Web.Cache; using Umbraco.Web.UI.Pages; namespace InfoCaster.Umbraco.UrlTracker @@ -48,9 +44,7 @@ protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplica ContentService.Publishing += ContentService_Publishing; ContentService.Deleting += ContentService_Deleting; content.BeforeClearDocumentCache += content_BeforeClearDocumentCache; - Domain.AfterDelete += Domain_AfterDelete; - Domain.AfterSave += Domain_AfterSave; - Domain.New += Domain_New; + DomainCacheRefresher.CacheUpdated += (s, e) => UmbracoHelper.ClearDomains(); } } @@ -176,20 +170,5 @@ void content_BeforeClearDocumentCache(Document doc, DocumentCacheEventArgs e) } #endif } - - void Domain_New(Domain sender, NewEventArgs e) - { - UmbracoHelper.ClearDomains(); - } - - void Domain_AfterSave(Domain sender, SaveEventArgs e) - { - UmbracoHelper.ClearDomains(); - } - - void Domain_AfterDelete(Domain sender, umbraco.cms.businesslogic.DeleteEventArgs e) - { - UmbracoHelper.ClearDomains(); - } } } \ No newline at end of file