]> jfr.im git - uguu.git/commitdiff
Update Upload.php
authorGo Johansson <redacted>
Fri, 5 May 2023 23:52:30 +0000 (01:52 +0200)
committerGitHub <redacted>
Fri, 5 May 2023 23:52:30 +0000 (01:52 +0200)
src/Classes/Upload.php

index e7becc081b3af7afed0cd0fc3036df0315461239..e28bf891aafccff8a16d79fe9a18784be72029e1 100644 (file)
          *
          * @return string The file extension of the file.
          */
-        public function fileExtension(array $file):string
+        public function fileExtension(array $file):?string
         {
+            if(str_contains($file['name'], '.')){
             $extension = explode('.', $file['name']);
-            $dotCount = substr_count($file['name'], '.');
+            $dotCount = substr_count($file['name'], '.');    
             return match ($dotCount) {
-                0 => null,
                 1 => end($extension),
                 2 => $this->doubleDotExtension($extension),
                 default => end($extension)
             };
+            }
+            return "NOEXT";
         }
         
         /**
                     $index = rand(0, strlen($this->Connector->CONFIG['ID_CHARSET']) - 1);
                     $NEW_NAME .= $this->Connector->CONFIG['ID_CHARSET'][$index];
                 }
-                if (!empty($extension)) {
+                if ($extension != "NOEXT") {
                     $NEW_NAME .= '.' . $extension;
                 }
             } while ($this->Connector->dbCheckNameExists($NEW_NAME));
             return $NEW_NAME;
         }
-    }
\ No newline at end of file
+    }