diff options
Diffstat (limited to 'core/src/main/kotlin/resolvers')
-rw-r--r-- | core/src/main/kotlin/resolvers/DefaultLocationProvider.kt | 4 | ||||
-rw-r--r-- | core/src/main/kotlin/resolvers/LocationProvider.kt | 1 |
2 files changed, 4 insertions, 1 deletions
diff --git a/core/src/main/kotlin/resolvers/DefaultLocationProvider.kt b/core/src/main/kotlin/resolvers/DefaultLocationProvider.kt index d7089f96..3412d975 100644 --- a/core/src/main/kotlin/resolvers/DefaultLocationProvider.kt +++ b/core/src/main/kotlin/resolvers/DefaultLocationProvider.kt @@ -38,6 +38,8 @@ open class DefaultLocationProvider( else -> ancestors(node.parent()) + node } + override fun top(): PageNode = pageGraphRoot + protected open fun findInPageGraph(dri: DRI, platforms: List<PlatformData>): PageNode? = pageGraphRoot.dfs { it.dri == dri } @@ -52,7 +54,7 @@ open class DefaultLocationProvider( else -> getPath(pathNode.parent(), path + pathNode.pathName().ifEmpty { "root" }) } - val contextNode = if (context?.children?.isEmpty() == true) context.parent() else context + val contextNode = if (context?.children?.isEmpty() == true && context.parent() != null) context.parent() else context val nodePath = getPath(node).reversed() val contextPath = getPath(contextNode).reversed() diff --git a/core/src/main/kotlin/resolvers/LocationProvider.kt b/core/src/main/kotlin/resolvers/LocationProvider.kt index 2da2310d..7d77ccb8 100644 --- a/core/src/main/kotlin/resolvers/LocationProvider.kt +++ b/core/src/main/kotlin/resolvers/LocationProvider.kt @@ -9,4 +9,5 @@ interface LocationProvider { fun resolve(node: PageNode, context: PageNode? = null): String fun resolveRoot(node: PageNode): String fun ancestors(node: PageNode?): List<PageNode> + fun top(): PageNode } |