ADarko22 commented on a change in pull request #392:
URL: https://github.com/apache/tika/pull/392#discussion_r541577370



##########
File path: 
tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-pkg-module/src/main/java/org/apache/tika/parser/pkg/CompressorParser.java
##########
@@ -213,22 +213,15 @@ public boolean decompressConcatenated(Metadata metadata) {
             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")) {

Review comment:
       We could have a static method
   ` 
     public static boolean endsWithAnyOf(String string, String... suffixes) {
       return Stream.of(suffixes)
           .filter(Objects::nonNull)
           .anyMatch(string::endsWith);
     }
   `
   and  then
   `
   if(endsWithAnyOf(name, ".tbz", ".tbz2")){
   ..
   }else if(endsWithAnyOf(name, ".bz", ".bz2", ".xz", ".zlib", ".pack", ".br")){
   ..
   }
   `
   not sure where could be the best place for: `public static boolean 
endsWithAnyOf(String string, String... suffixes)`




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to