Commit f2c64ea4c353701dfcec6475cc433a23619d6d97

Thomas de Grivel 2022-01-07T11:34:14

fix inline files

diff --git a/lib/kmxgit_web/controllers/repository_controller.ex b/lib/kmxgit_web/controllers/repository_controller.ex
index 6dbf92c..69aca52 100644
--- a/lib/kmxgit_web/controllers/repository_controller.ex
+++ b/lib/kmxgit_web/controllers/repository_controller.ex
@@ -235,11 +235,11 @@ defmodule KmxgitWeb.RepositoryController do
     git
   end
 
-  defp default_mime(content) do
+  defp mime_type(content, ext \\ nil) do
     if String.valid?(content) do
       "text/plain"
     else
-      "application/octet-stream"
+      MIME.type(ext)
     end
   end
 
@@ -248,9 +248,10 @@ defmodule KmxgitWeb.RepositoryController do
       case GitManager.content(Repository.full_slug(repo), sha1) do
         {:ok, content} ->
           type = case Regex.run(~r/[.]([^.]+)$/, path) do
-                   [_, ext] -> MIME.type(ext) || default_mime(content)
-                   _ -> default_mime(content)
+                   [_, ext] -> mime_type(content, ext)
+                   _ -> mime_type(content)
                  end
+          IO.inspect(path: path, name: name, type: type)
           %{git | content: content, content_type: type, filename: name}
         {:error, error} -> %{git | status: error}
       end