You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by fs...@apache.org on 2020/02/09 11:09:58 UTC

[tomcat-jakartaee-migration] branch master updated: Don't return null on empty extensions

This is an automated email from the ASF dual-hosted git repository.

fschumacher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat-jakartaee-migration.git


The following commit(s) were added to refs/heads/master by this push:
     new 86b8370  Don't return null on empty extensions
86b8370 is described below

commit 86b8370a714167d86c3fe72be721331658586862
Author: Felix Schumacher <fe...@internetallee.de>
AuthorDate: Sun Feb 9 12:09:46 2020 +0100

    Don't return null on empty extensions
    
    Make it easier for the consumer to handle our answers.
---
 src/main/java/org/apache/tomcat/jakartaee/Util.java | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/tomcat/jakartaee/Util.java b/src/main/java/org/apache/tomcat/jakartaee/Util.java
index 25f063f..21e0fbf 100644
--- a/src/main/java/org/apache/tomcat/jakartaee/Util.java
+++ b/src/main/java/org/apache/tomcat/jakartaee/Util.java
@@ -25,11 +25,18 @@ public class Util {
     private static Pattern PATTERN = Pattern.compile(
             "javax([/\\.](annotation|ejb|el|mail|persistence|security[/\\.]auth[/\\.]message|servlet|transaction|websocket))");
 
+    /**
+     * Get the extension of a filename
+     * <p>
+     * The extension is the string after the last '{@code .}' in the filename.
+     * @param filename the name of the file
+     * @return the extension or an empty string, if no dot is found in the filename
+     */
     public static String getExtension(String filename) {
         // Extract the extension
         int lastPeriod = filename.lastIndexOf('.');
         if (lastPeriod == -1) {
-            return null;
+            return "";
         }
         return filename.substring(lastPeriod + 1).toLowerCase(Locale.ENGLISH);
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org