Recognize wildcards in media types with a suffix

The "includes" and "isCompatibleWith" methods of MediaType take into
account media types with suffices (e.g. application/soap+xml) including
wildcards with suffices (e.g. application/*+xml). However before this
change, the isWildcardSubtype() method returned true only for subtype
"*". Now a media type such as application/*+xml is also recognized as
having a wildcard subtype.

Issue: SPR-9841
This commit is contained in:
Rossen Stoyanchev
2012-10-06 10:20:14 -04:00
parent 2c8b7fe093
commit 01d8d64200
3 changed files with 31 additions and 2 deletions

View File

@@ -413,11 +413,12 @@ public class MediaType implements Comparable<MediaType> {
}
/**
* Indicates whether the {@linkplain #getSubtype() subtype} is the wildcard character <code>&#42;</code> or not.
* Indicates whether the {@linkplain #getSubtype() subtype} is the wildcard character <code>&#42;</code>
* or the wildcard character followed by a sufiix (e.g. <code>&#42;+xml</code>), or not.
* @return whether the subtype is <code>&#42;</code>
*/
public boolean isWildcardSubtype() {
return WILDCARD_TYPE.equals(subtype);
return WILDCARD_TYPE.equals(subtype) || subtype.startsWith("*+");
}
/**