From f074dee887629bcd6553098a64d41ff2e154db80 Mon Sep 17 00:00:00 2001 From: leekelleher Date: Wed, 6 Feb 2019 16:05:40 +0000 Subject: [PATCH 1/2] Bumping version number for hotfixes [skip ci] --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index d2ec2a9..768af2a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,7 @@ image: Visual Studio 2017 # version format -version: 2.0.3.{build} +version: 2.0.4.{build} # UMBRACO_PACKAGE_PRERELEASE_SUFFIX if a rtm release build this should be blank, otherwise if empty will default to alpha # example UMBRACO_PACKAGE_PRERELEASE_SUFFIX=beta From 1e063a733f10c6c4fffc82b7226bd01e532fc515 Mon Sep 17 00:00:00 2001 From: leekelleher Date: Wed, 13 Feb 2019 13:50:40 +0000 Subject: [PATCH 2/2] Fixes #66 When a page is unpublished, the URL is "#", which isn't a valid URI, so an error is thrown. Now we detect this and use a fallback URI from the current request. --- .../Web/Controllers/StackedContentApiController.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Our.Umbraco.StackedContent/Web/Controllers/StackedContentApiController.cs b/src/Our.Umbraco.StackedContent/Web/Controllers/StackedContentApiController.cs index 236cecd..3126139 100644 --- a/src/Our.Umbraco.StackedContent/Web/Controllers/StackedContentApiController.cs +++ b/src/Our.Umbraco.StackedContent/Web/Controllers/StackedContentApiController.cs @@ -33,8 +33,17 @@ public HttpResponseMessage GetPreviewMarkup([FromBody] JObject item, int pageId) // Ensure PublishedContentRequest exists, just in case there are any RTE Macros to render if (UmbracoContext.PublishedContentRequest == null) { + var pageUrl = page.UrlAbsolute(); + + // If the page is unpublished, then the URL will be empty or a hash '#'. + // Use the current request as a fallback, as we need to give the PublishedContentRequest a URI. + if (string.IsNullOrEmpty(pageUrl) || pageUrl.Equals("#")) + { + pageUrl = string.Concat(Request.RequestUri.GetLeftPart(UriPartial.Authority), "/#", pageId); + } + #pragma warning disable CS0618 // Type or member is obsolete - var pcr = new PublishedContentRequest(new Uri(page.UrlAbsolute()), UmbracoContext.RoutingContext); + var pcr = new PublishedContentRequest(new Uri(pageUrl), UmbracoContext.RoutingContext); #pragma warning restore CS0618 // Type or member is obsolete UmbracoContext.PublishedContentRequest = pcr;