Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 0db22c7d authored by Ricki Hirner's avatar Ricki Hirner Committed by GitHub
Browse files

Fix `Response` not appending trailing slash to collections (#130)

* Fix empty filterIsInstance in Ktor and OkHttp responses

- Change `map` to `flatMap` for properties in both Ktor and OkHttp response handling
- Ensure `filterIsInstance<ResourceType>` works correctly by flattening the properties list

* Fix tests
parent bcb30026
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -180,7 +180,7 @@ data class Response(
            // if we know this resource is a collection, make sure href has a trailing slash
            // (for clarity and resolving relative paths)
            propStat.filter { it.status.isSuccess() }
                .map { it.properties }
                .flatMap { it.properties }
                .filterIsInstance<ResourceType>()
                .firstOrNull()
                ?.let { type ->
+1 −1
Original line number Diff line number Diff line
@@ -176,7 +176,7 @@ data class Response(
            // if we know this resource is a collection, make sure href has a trailing slash
            // (for clarity and resolving relative paths)
            propStat.filter { it.isSuccess() }
                .map { it.properties }
                .flatMap { it.properties }
                .filterIsInstance<ResourceType>()
                .firstOrNull()
                ?.let { type ->
+1 −1
Original line number Diff line number Diff line
@@ -924,7 +924,7 @@ class DavResourceTest {
                }
            }
        }
        assertEquals(4, nrCalled)
        assertEquals(5, nrCalled)
    }

    @Test
+1 −1
Original line number Diff line number Diff line
@@ -848,7 +848,7 @@ class DavResourceTest {
                }
            }
        }
        assertEquals(4, nrCalled)
        assertEquals(5, nrCalled)


        /*** SPECIAL CASES ***/