is this CORS code too "clever" ? ``` val header = ...
# announcements
t
is this CORS code too "clever" ?
Copy code
val header = ctx.header("Origin") ?: ctx.header("Referer") ?: return
origins.filter { header.startsWith(it) }.firstOrNull()?.let {
    ctx.header("Access-Control-Allow-Origin", it)
}
p
yeah
It's not obvious to me what are you doing.
d
You can do
origins.firstOrNull { header.startsWith(it) }
instead of filter + firstOrNull
t
@dmitry.petrov thanks, that helps a lot. is the chained elvis common/acceptable ?
d
Yeah, that's fine. I write similar code myself.
t
great, thanks