https://kotlinlang.org logo
Title
s

Sergey Akhapkin

03/25/2020, 11:29 PM
Hi folks, I've a strange issue with nested locations in Ktor (1.3.1 and 1.3.2), let assume there are some defined locations
@KtorExperimentalLocationsAPI
@Location("/auth")
object Auth {
    @Location("/phone")
    object ByPhone {
        @Location("/confirm")
        object Confirmation
    }
}
and I've a simple test:
@Test
    fun authLocationsTest() {
        withTestApplication {
            assertEquals("/auth",  application.locations.href(Auth))
            assertEquals("/auth/phone",  application.locations.href(Auth.ByPhone))
            assertEquals("/auth/phone/confirm",  application.locations.href(Auth.ByPhone.Confirmation))
        }
    }
which is failed with:
Expected :/auth/phone/confirm
Actual   :/phone/confirm
Is that expected behavior and somehow related to https://github.com/ktorio/ktor/issues/1660 or I should file a bug report ?
Just to note:
@KtorExperimentalLocationsAPI
@Location("/auth")
object Auth {
    @Location("/phone")
    object ByPhone {
        @Location("/confirm")
        class Confirmation(val byPhone: ByPhone = ByPhone)
    }
}
this code (plus expected changes to test) works as expected. Perhaps it should be reflected better in documentation then.