mirror of https://github.com/usbharu/Hideout.git
fix: ContentTypeの判定を修正
This commit is contained in:
parent
6ae140a58d
commit
b0551ade76
|
@ -34,10 +34,10 @@ class ContentTypeRouteSelector(private vararg val contentType: ContentType) : Ro
|
|||
override fun evaluate(context: RoutingResolveContext, segmentIndex: Int): RouteSelectorEvaluation {
|
||||
|
||||
context.call.application.log.debug("Accept: ${context.call.request.accept()}")
|
||||
val requestContentType =
|
||||
ContentType.parse(context.call.request.accept() ?: return RouteSelectorEvaluation.FailedParameter)
|
||||
|
||||
return if (contentType.find { contentType: ContentType -> contentType.match(requestContentType) } != null) {
|
||||
val requestContentType = context.call.request.accept() ?: return RouteSelectorEvaluation.FailedParameter
|
||||
return if (requestContentType.split(",")
|
||||
.find { contentType.find { contentType -> contentType.match(it) } != null } != null
|
||||
) {
|
||||
RouteSelectorEvaluation.Constant
|
||||
} else {
|
||||
RouteSelectorEvaluation.FailedParameter
|
||||
|
|
|
@ -170,9 +170,11 @@ class UsersAPTest {
|
|||
@Test
|
||||
// @Disabled
|
||||
fun contentType_Test() {
|
||||
|
||||
assertTrue(ContentType.Application.Activity.match("application/activity+json"))
|
||||
val listOf = listOf(ContentType.Application.JsonLd, ContentType.Application.Activity)
|
||||
assertTrue(listOf.find { contentType ->
|
||||
contentType.match("application/ld+json; profile=\"\\\"https://www.w3.org/ns/activitystreams\\\",application/activity+json\"")
|
||||
contentType.match("application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"")
|
||||
}.let { it != null })
|
||||
assertTrue(ContentType.Application.JsonLd.match("application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue