Simplify substring() usage in MimeTypeUtils

Closes gh-24933
This commit is contained in:
Mikael 2020-04-19 18:39:06 +03:00 committed by GitHub
parent 3dadcaeb2d
commit d6c9c7d642
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -219,7 +219,7 @@ public abstract class MimeTypeUtils {
throw new InvalidMimeTypeException(mimeType, "does not contain subtype after '/'"); throw new InvalidMimeTypeException(mimeType, "does not contain subtype after '/'");
} }
String type = fullType.substring(0, subIndex); String type = fullType.substring(0, subIndex);
String subtype = fullType.substring(subIndex + 1, fullType.length()); String subtype = fullType.substring(subIndex + 1);
if (MimeType.WILDCARD_TYPE.equals(type) && !MimeType.WILDCARD_TYPE.equals(subtype)) { if (MimeType.WILDCARD_TYPE.equals(type) && !MimeType.WILDCARD_TYPE.equals(subtype)) {
throw new InvalidMimeTypeException(mimeType, "wildcard type is legal only in '*/*' (all mime types)"); throw new InvalidMimeTypeException(mimeType, "wildcard type is legal only in '*/*' (all mime types)");
} }
@ -248,7 +248,7 @@ public abstract class MimeTypeUtils {
int eqIndex = parameter.indexOf('='); int eqIndex = parameter.indexOf('=');
if (eqIndex >= 0) { if (eqIndex >= 0) {
String attribute = parameter.substring(0, eqIndex).trim(); String attribute = parameter.substring(0, eqIndex).trim();
String value = parameter.substring(eqIndex + 1, parameter.length()).trim(); String value = parameter.substring(eqIndex + 1).trim();
parameters.put(attribute, value); parameters.put(attribute, value);
} }
} }