Commit 3953bd97c70bc981cd144b8b1ca37f05ff7c43ee

Thomas de Grivel 2023-02-03T15:01:48

add / at end of directory URLs

diff --git a/lib/kmxgit_web/controllers/repository_controller.ex b/lib/kmxgit_web/controllers/repository_controller.ex
index 54838ab..141751c 100644
--- a/lib/kmxgit_web/controllers/repository_controller.ex
+++ b/lib/kmxgit_web/controllers/repository_controller.ex
@@ -498,15 +498,15 @@ defmodule KmxgitWeb.RepositoryController do
     end
   end
   defp show_op(conn, op = :tree, %{tree: tree, git: git, org: org, path: path, repo: repo, user: user}) do
-    if ! String.match?(conn.request_path, ~r(/$)) do
+    git = git
+    |> git_put_files(repo, tree, path, conn)
+    |> git_put_content(repo, path)
+    |> git_put_readme(repo)
+    |> git_put_log1(repo, tree, path)
+    |> git_put_tags(repo, conn, op, path)
+    if (git.content == nil) && ! String.match?(conn.request_path, ~r(/$)) do
       redirect conn, to: conn.request_path <> "/"
     else
-      git = git
-      |> git_put_files(repo, tree, path, conn)
-      |> git_put_content(repo, path)
-      |> git_put_readme(repo)
-      |> git_put_log1(repo, tree, path)
-      |> git_put_tags(repo, conn, op, path)
       conn
       |> assign_current_organisation(org)
       |> assign(:current_repository, repo)
diff --git a/lib/kmxgit_web/templates/layout/nav_connected.html.heex b/lib/kmxgit_web/templates/layout/nav_connected.html.heex
index 0b64dc8..70fd7c3 100644
--- a/lib/kmxgit_web/templates/layout/nav_connected.html.heex
+++ b/lib/kmxgit_web/templates/layout/nav_connected.html.heex
@@ -1,23 +1,23 @@
 <%= if @conn.assigns[:current_repository] do %>
   <li class="nav-item">
     <%= link Repository.full_slug(@repo),
-             to: Routes.repository_path(@conn, :show, Repository.owner_slug(@repo), Repository.splat(@repo)),
+             to: Routes.repository_path(@conn, :show, Repository.owner_slug(@repo), Repository.splat(@repo)) <> "/",
              class: "nav-link" %>
   </li>
 <% end %>
 <%= if @conn.assigns[:current_organisation] do %>
   <li class="nav-item">
     <%= link @current_organisation.name || @current_organisation.slug_,
-             to: Routes.slug_path(@conn, :show, @current_organisation.slug_),
+             to: Routes.slug_path(@conn, :show, @current_organisation.slug_) <> "/",
              class: "nav-link" %>
   </li>
 <% end %>
 <li class="nav-item">
-  <%= link User.login(@current_user), to: Routes.slug_path(@conn, :show, User.login(@current_user)), class: "nav-link" %>
+  <%= link User.login(@current_user), to: Routes.slug_path(@conn, :show, User.login(@current_user)) <> "/", class: "nav-link" %>
 </li>
 <%= if @current_user.is_admin do %>
   <li class="nav-item">
-    <%= link gettext("Admin"), to: Routes.admin_dashboard_path(@conn, :index), class: "nav-link" %>
+    <%= link gettext("Admin"), to: Routes.admin_dashboard_path(@conn, :index) <> "/", class: "nav-link" %>
   </li>
 <% end %>
 <li class="nav-item">
diff --git a/lib/kmxgit_web/templates/repository/show_files.html.heex b/lib/kmxgit_web/templates/repository/show_files.html.heex
index cfb7d59..35506f1 100644
--- a/lib/kmxgit_web/templates/repository/show_files.html.heex
+++ b/lib/kmxgit_web/templates/repository/show_files.html.heex
@@ -18,7 +18,7 @@
                   <%= file.name %>
                 <% end %>
               <% :tree -> %>
-                <%= link to: file.url do %>
+                <%= link to: "#{file.url}/" do %>
                   <i class="fa fa-folder fixed-width"></i>
                   <%= "#{file.name}/" %>
                 <% end %>