Simplify method CompressorParser#parse
@@ -211,22 +211,15 @@ public class CompressorParser extends AbstractParser {
Metadata entrydata = new Metadata();
String name = metadata.get(TikaCoreProperties.RESOURCE_NAME_KEY);
if (name != null) {
- if (name.endsWith(".tbz")) {
- name = name.substring(0, name.length() - 4) + ".tar";
- } else if (name.endsWith(".tbz2")) {
- name = name.substring(0, name.length() - 5) + ".tar";
- } else if (name.endsWith(".bz")) {
- name = name.substring(0, name.length() - 3);
- } else if (name.endsWith(".bz2")) {
- name = name.substring(0, name.length() - 4);
- } else if (name.endsWith(".xz")) {
- name = name.substring(0, name.length() - 3);
- } else if (name.endsWith(".zlib")) {
- name = name.substring(0, name.length() - 5);
- } else if (name.endsWith(".pack")) {
- name = name.substring(0, name.length() - 5);
- } else if (name.endsWith(".br")) {
- name = name.substring(0, name.length() - 3);
+ if (name.endsWith(".tbz") || name.endsWith(".tbz2")) {
+ name = name.substring(0, name.lastIndexOf(".")) + ".tar";
+ } else if (name.endsWith(".bz") ||
+ name.endsWith(".bz2") ||
+ name.endsWith(".xz") ||
+ name.endsWith(".zlib") ||
+ name.endsWith(".pack") ||
+ name.endsWith(".br")) {
+ name = name.substring(0, name.lastIndexOf("."));
} else if (name.length() > 0) {
name = GzipUtils.getUncompressedFilename(name);
}
