Fix slashes in string concat calls
authorLanius Trolling <lanius@laniustrolling.dev>
Sun, 22 Dec 2024 19:32:09 +0000 (14:32 -0500)
committerLanius Trolling <lanius@laniustrolling.dev>
Sun, 22 Dec 2024 19:32:09 +0000 (14:32 -0500)
src/main/kotlin/info/mechyrdia/data/DataFiles.kt
src/main/kotlin/info/mechyrdia/lore/ParserPreprocess.kt
src/main/kotlin/info/mechyrdia/route/ResourceWebDav.kt

index 7e081d7421ab8d87e37ec2a60b1e502baf148ff5..6813dfa9c22aa3ab9583f42e5a585af8e53f481a 100644 (file)
@@ -294,8 +294,8 @@ private data class GridFsEntry(
 ) : DataDocument<GridFsEntry>
 
 private class GridFsStorage(val table: DocumentTable<GridFsEntry>, val bucket: GridFSBucket) : FileStorage {
-       private fun toExactPath(path: StoragePath) = path.elements.concat("/", prefix = "/")
-       private fun toPrefixPath(path: StoragePath) = path.elements.concat("/", prefix = "/", suffix = "/")
+       private fun toExactPath(path: StoragePath) = path.elements.map { "/$it" }.concat()
+       private fun toPrefixPath(path: StoragePath) = path.elements.map { "/$it" }.concat(suffix = "/")
        
        private suspend fun testExact(path: StoragePath) = table.number(Filters.eq(GridFsEntry::path.serialName, toExactPath(path))) > 0L
        private suspend fun getExact(path: StoragePath) = table.locate(Filters.eq(GridFsEntry::path.serialName, toExactPath(path)))
index 6f1e07d26c0d4c7503d2fa704ba913d1581d9934..188e89c551ce5c7c82a40cb1e14b13a9f191053a 100644 (file)
@@ -48,7 +48,7 @@ class PreProcessorContext private constructor(
                fun defaults(lorePath: StoragePath) = defaults(lorePath.elements.drop(1))
                
                fun defaults(lorePath: List<String>) = mapOf(
-                       PAGE_PATH_KEY to lorePath.concat("/", prefix = "/").textToTree(),
+                       PAGE_PATH_KEY to lorePath.map { "/$it" }.concat().textToTree(),
                        INSTANT_NOW_KEY to Instant.now().toEpochMilli().numberToTree(),
                )
        }
index d9fd4844f9570bf475e4bab91f774ba908bdfcc8..0425c378e4d3f8750f020344972390ba92dca9c3 100644 (file)
@@ -133,7 +133,7 @@ private suspend fun getWebDavPropertiesWithIncludeTags(path: StoragePath, webRoo
                        .filterNotNull()
                        .flatten()
                
-               val pathWithSuffix = path.elements.concat("/", suffix = "/")
+               val pathWithSuffix = path.elements.map { "$it/" }.concat()
                listOf(
                        WebDavProperties.Collection(
                                creationDate = subProps.mapNotNull { it.first.creationDate }.maxOrNull(),