Merge pull request #928 from mhartsock/SPR-13747
This commit is contained in:
@@ -95,10 +95,12 @@ public class MappingMediaTypeFileExtensionResolver implements MediaTypeFileExten
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method for a reverse lookup from extension to MediaType.
|
||||
* Use this method for a reverse, case-insensitive MediaType lookup.
|
||||
* @param extension the extension to look up
|
||||
* @return a MediaType for the key or {@code null}
|
||||
*/
|
||||
protected MediaType lookupMediaType(String extension) {
|
||||
extension = extension.toLowerCase(Locale.ENGLISH);
|
||||
return this.mediaTypes.get(extension);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -51,4 +51,14 @@ public class MappingMediaTypeFileExtensionResolverTests {
|
||||
assertTrue(extensions.isEmpty());
|
||||
}
|
||||
|
||||
// SPR-13747
|
||||
|
||||
@Test
|
||||
public void lookupMediaTypeCaseInsensitive() {
|
||||
Map<String, MediaType> mapping = Collections.singletonMap("json", MediaType.APPLICATION_JSON);
|
||||
MappingMediaTypeFileExtensionResolver resolver = new MappingMediaTypeFileExtensionResolver(mapping);
|
||||
MediaType mediaType = resolver.lookupMediaType("JSON");
|
||||
|
||||
assertEquals(mediaType, MediaType.APPLICATION_JSON);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user