Merge pull request #3664 from tian-pengfei/v5-master-contentType

增加ContentType#get识别的准确率。
This commit is contained in:
Golden Looly
2024-07-31 00:18:13 +08:00
committed by GitHub
2 changed files with 10 additions and 0 deletions

View File

@@ -16,4 +16,13 @@ public class ContentTypeTest {
String result = ContentType.build(ContentType.JSON, CharsetUtil.CHARSET_UTF_8);
Assert.assertEquals("application/json;charset=UTF-8", result);
}
@Test
public void testGetWithLeadingSpace() {
String json = " {\n" +
" \"name\": \"hutool\"\n" +
" }";
ContentType contentType = ContentType.get(json);
Assert.assertEquals(ContentType.JSON, contentType);
}
}