diff --git a/config/routes.rb b/config/routes.rb
index 0a4b86092526f101e725620721cc26040f065d8d..5c1460b0e75b97778c49d95f2e2f7f78b3528d09 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -735,7 +735,8 @@ Rails.application.routes.draw do
 
         resources :artifacts, only: [] do
           collection do
-            get :search, path: ':ref/:build_name(/*path)', format: false
+            get :search, path: ':ref/:build_name/*path', format: false,
+                         constraints: { ref: %r{.+(?=/)} } # ref could have /
           end
         end