Repository: ktorio/ktor
File: ktor-http/common/test/io/ktor/tests/http/ContentTypeLookupTest.kt (Kotlin)

Code before:
            ContentType.fromFileExtension(".zip")
        )

        assertEquals(
            listOf(
                ContentType.parse("video/mpeg"),
                ContentType.parse("audio/mpeg")
            ),
            ContentType.fromFileExtension(".mpg")
        )

        assertEquals(
            listOf(
                ContentType.parse("video/mp4"),
                ContentType.parse("application/mp4")
            ),
            ContentType.fromFileExtension(".mp4")
        )

        assertEquals(
            listOf(
                ContentType.parse("text/javascript"),
                ContentType.parse("application/javascript"),
            ),
            ContentType.fromFileExtension(".js")
        )
    }

    @Test
    fun testMissing() {
        assertEquals(emptyList(), ContentType.fromFileExtension(".werfewrfgewrf"))
    }

    @Test
    fun testEmpty() {
        assertEquals(emptyList(), ContentType.fromFileExtension(""))
        assertEquals(emptyList(), ContentType.fromFileExtension("."))
    }

    @Test
    fun testWrongCharacterCase() {
        assertEquals(plainText, ContentType.fromFileExtension(".Txt"))
    }

    @Test
    fun testMissingDot() {
        assertEquals(plainText, ContentType.fromFileExtension("txt"))
    }

    @Test
    fun testByPathNoPath() {

Review comment (suggestion):
Related tests like 

https://github.com/ktorio/ktor/blob/d67df05f01020955d241d62425eaddb67be905ee/ktor-http/common/test/io/ktor/tests/http/ContentTypeLookupTest.kt#L49-L55

https://github.com/ktorio/ktor/blob/d67df05f01020955d241d62425eaddb67be905ee/ktor-http/common/test/io/ktor/tests/http/ContentTypeLookupTest.kt#L57-L63

should be corrected too. As the

- tyep for `audio/mpeg` should be `mpga`, see
  - https://mimetype.io/audio/mpeg
  - https://github.com/apache/httpd/blob/befb52370cf75df77751393d7c3b06146c99d8a3/docs/conf/mime.types#L1442
- type for `application/mp4` should be `mp4s`, see
  - https://mimetype.io/application/mp4
  - https://github.com/apache/httpd/blob/befb52370cf75df77751393d7c3b06146c99d8a3/docs/conf/mime.types#L202

Code after:
            ContentType.fromFileExtension(".zip")
        )

        assertEquals(
            listOf(
                ContentType.parse("text/javascript"),
                ContentType.parse("application/javascript"),
            ),
            ContentType.fromFileExtension(".js")
        )
    }

    @Test
    fun testMissing() {
        assertEquals(emptyList(), ContentType.fromFileExtension(".werfewrfgewrf"))
    }

    @Test
    fun testEmpty() {
        assertEquals(emptyList(), ContentType.fromFileExtension(""))
        assertEquals(emptyList(), ContentType.fromFileExtension("."))
    }

    @Test
    fun testWrongCharacterCase() {
        assertEquals(plainText, ContentType.fromFileExtension(".Txt"))
    }

    @Test
    fun testMissingDot() {
        assertEquals(plainText, ContentType.fromFileExtension("txt"))
    }

    @Test
    fun testByPathNoPath() {
        assertEquals(plainText, ContentType.fromFilePath("aa.txt"))
    }

    @Test
    fun testByPathNoExtNoReg() {
        assertEquals(emptyList(), ContentType.fromFilePath("aa"))
    }

    @Test
    fun testByPathNoExt() {
        assertEquals(emptyList(), ContentType.fromFilePath("txt"))
    }

    @Test
    fun testByPathWithPath() {
        assertEquals(plainText, ContentType.fromFilePath("/path/to/file/aa.txt"))