[ 
https://issues.apache.org/jira/browse/TIKA-4882?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18112978#comment-18112978
 ] 

ASF GitHub Bot commented on TIKA-4882:
--------------------------------------

tballison commented on PR #3142:
URL: https://github.com/apache/tika/pull/3142#issuecomment-5590936152

   Thank you for opening this!
   
   In looking at the codebase, I realize that we let duplicative call sites 
arise, which we shouldn't have.
   
   EmbeddedDocumentUtil.getExtensionForMediaType(String) already basically does 
what FileNameUtils does, with some difference input and default missing value.
   
   We should put this functionality in one, along the lines of: 
   
   ```
     public static String calculateExtension(Metadata metadata, String 
defaultValue) {
         String ext = EmbeddedDocumentUtil.getExtensionForMediaType(
                 metadata.get(HttpHeaders.CONTENT_TYPE));
         return StringUtils.isBlank(ext) ? defaultValue : ext;
     }
   
   ```
   
   Perhaps on a follow on PR, put `public String getExtension(String name) {} 
in MimeTypes and then call from there?
   
   Consider deprecating the two current call sites that are nearly duplicative?




> FilenameUtils.calculateExtension ignores defaultValue on unknown path
> ---------------------------------------------------------------------
>
>                 Key: TIKA-4882
>                 URL: https://issues.apache.org/jira/browse/TIKA-4882
>             Project: Tika
>          Issue Type: Bug
>          Components: core
>            Reporter: Tim Grein
>            Priority: Minor
>
> FilenameUtils.calculateExtension ignores an unknown extension in the sense 
> that the behavior on an unknown extension is not specified in the javadoc and 
> it's not explicitly handled. It should probably be either handled or 
> explicitly documented.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to