diff --git a/ktor-http/common/src/io/ktor/http/FileContentType.kt b/ktor-http/common/src/io/ktor/http/FileContentType.kt index 1ae65776c13..9c91e0f77a0 100644 --- a/ktor-http/common/src/io/ktor/http/FileContentType.kt +++ b/ktor-http/common/src/io/ktor/http/FileContentType.kt @@ -65,8 +65,12 @@ private val extensionsByContentType: Map> by lazy { internal fun List.selectDefault(): ContentType { val contentType = firstOrNull() ?: ContentType.Application.OctetStream return when { - contentType.match(ContentType.Text.Any) && contentType.charset() == null -> contentType.withCharset(Charsets.UTF_8) - contentType.match(ContentType.Image.SVG) && contentType.charset() == null -> contentType.withCharset(Charsets.UTF_8) + contentType.match(ContentType.Text.Any) + && contentType.charset() == null -> contentType.withCharset(Charsets.UTF_8) + + contentType.match(ContentType.Image.SVG) + && contentType.charset() == null -> contentType.withCharset(Charsets.UTF_8) + else -> contentType } } diff --git a/ktor-server/ktor-server-tests/jvm/test/io/ktor/server/plugins/StaticContentTest.kt b/ktor-server/ktor-server-tests/jvm/test/io/ktor/server/plugins/StaticContentTest.kt index cb85b1697b8..8b5dd33349a 100644 --- a/ktor-server/ktor-server-tests/jvm/test/io/ktor/server/plugins/StaticContentTest.kt +++ b/ktor-server/ktor-server-tests/jvm/test/io/ktor/server/plugins/StaticContentTest.kt @@ -1268,7 +1268,7 @@ class StaticContentTest { } extensions.forEach { (extension, contentType) -> - client.get("/${fileName}.${extension}").apply { + client.get("/$fileName.$extension").apply { assertEquals(contentType.withCharset(Charsets.UTF_8), contentType()) } }