[chronojump] Better addExtensionIfNeeded method



commit c8bee9df3b9d895286c580776a49e306aa22c869
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Jan 30 22:04:48 2018 +0100

    Better addExtensionIfNeeded method

 src/util.cs |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)
---
diff --git a/src/util.cs b/src/util.cs
index b1ad7d7..cd13963 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -1674,11 +1674,10 @@ public class Util
        }
        private static string addExtensionIfNeeded(string myFile, string extension)
        {
-               int posOfDot = myFile.LastIndexOf('.');
-               if (posOfDot == -1) 
-                       myFile += extension;
-               
-               return myFile;
+               if(myFile.ToLower().EndsWith(extension))
+                       return myFile;
+
+               return myFile + extension;
        }
 
        public static string RemoveExtension(string myFile)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]