diff --git a/lib/kmxgit_web/controllers/repository_controller.ex b/lib/kmxgit_web/controllers/repository_controller.ex
index 5a799d4..7e08a64 100644
--- a/lib/kmxgit_web/controllers/repository_controller.ex
+++ b/lib/kmxgit_web/controllers/repository_controller.ex
@@ -112,7 +112,7 @@ defmodule KmxgitWeb.RepositoryController do
if git.valid do
conn
|> assign(:branch, branch1)
- |> assign(:branch_url, Routes.repository_path(conn, :show, Repository.owner_slug(repo), Repository.splat(repo) ++ ["_branch", branch1]))
+ |> assign(:branch_url, Routes.repository_path(conn, :show, Repository.owner_slug(repo), Repository.splat(repo, if branch1 do ["_branch", branch1] else [] end)))
|> assign_current_organisation(org)
|> assign(:current_repository, repo)
|> assign(:git, git)