Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/Umbraco.Core/DeliveryApi/ApiContentPathResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public ApiContentPathResolver(IRequestRoutingService requestRoutingService, IApi
_apiPublishedContentCache = apiPublishedContentCache;
}

[Obsolete("No longer used in V15. Scheduled for removal in V15.")]
public virtual bool IsResolvablePath(string path)
{
// File requests will blow up with an downstream exception in GetRequiredPublishedSnapshot, which fails due to an UmbracoContext
Expand All @@ -30,7 +31,10 @@ public virtual bool IsResolvablePath(string path)
return true;
}

private static bool IsFileRequest(string path) => path.Split('/', StringSplitOptions.RemoveEmptyEntries).Last().Contains('.');
private static bool IsFileRequest(string path) => path
.Split('/', StringSplitOptions.RemoveEmptyEntries)
.LastOrDefault()?
.Contains('.') is true;

public virtual IPublishedContent? ResolveContentPath(string path)
{
Expand Down
1 change: 1 addition & 0 deletions src/Umbraco.Core/DeliveryApi/IApiContentPathResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace Umbraco.Cms.Core.DeliveryApi;

public interface IApiContentPathResolver
{
[Obsolete("No longer used in V15. Scheduled for removal in V15.")]
bool IsResolvablePath(string path) => true;

IPublishedContent? ResolveContentPath(string path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class ApiContentPathResolverTests
private const string TestPath = "/test/page";

[TestCase(TestPath, true)]
[TestCase("/", true)]
[TestCase("file.txt", false)]
[TestCase("test/file.txt", false)]
[TestCase("test/test2/file.txt", false)]
Expand All @@ -24,11 +25,12 @@ public void Can_Verify_Resolveable_Paths(string path, bool expected)
Assert.AreEqual(expected, result);
}

[Test]
public void Resolves_Content_For_Path()
[TestCase(TestPath)]
[TestCase("/")]
public void Resolves_Content_For_Path(string path)
{
var resolver = CreateResolver();
var result = resolver.ResolveContentPath(TestPath);
var result = resolver.ResolveContentPath(path);
Assert.IsNotNull(result);
}

Expand All @@ -40,7 +42,10 @@ private static ApiContentPathResolver CreateResolver()
.Returns((string path) => path);
var mockApiPublishedContentCache = new Mock<IApiPublishedContentCache>();
mockApiPublishedContentCache
.Setup(x => x.GetByRoute(It.Is<string>(y => y == TestPath)))
.Setup(x => x.GetByRoute(TestPath))
.Returns(new Mock<IPublishedContent>().Object);
mockApiPublishedContentCache
.Setup(x => x.GetByRoute("/"))
.Returns(new Mock<IPublishedContent>().Object);
return new ApiContentPathResolver(mockRequestRoutingService.Object, mockApiPublishedContentCache.Object);
}
Expand Down
Loading