OSDN Git Service

Updated validations and routes to support dots in project names
authorJeremy Mack <jmacktdkc@gmail.com>
Mon, 12 Dec 2011 18:13:11 +0000 (13:13 -0500)
committerJeremy Mack <jmacktdkc@gmail.com>
Tue, 13 Dec 2011 18:20:45 +0000 (13:20 -0500)
app/models/project.rb
config/routes.rb

index a536131..85d5416 100644 (file)
@@ -25,7 +25,7 @@ class Project < ActiveRecord::Base
   validates :path,
             :uniqueness => true,
             :presence => true,
-            :format => { :with => /^[a-zA-Z0-9_\-]*$/,
+            :format => { :with => /^[a-zA-Z0-9_\-\.]*$/,
                          :message => "only letters, digits & '_' '-' allowed" },
             :length   => { :within => 0..255 }
 
@@ -35,7 +35,7 @@ class Project < ActiveRecord::Base
   validates :code,
             :presence => true,
             :uniqueness => true,
-            :format => { :with => /^[a-zA-Z0-9_\-]*$/,
+            :format => { :with => /^[a-zA-Z0-9_\-\.]*$/,
                          :message => "only letters, digits & '_' '-' allowed"  },
             :length   => { :within => 3..255 }
 
index 27d0612..1fbbbfd 100644 (file)
@@ -6,7 +6,7 @@ Gitlab::Application.routes.draw do
 
   namespace :admin do
     resources :users
-    resources :projects
+    resources :projects, :constraints => { :id => /[^\/]+/ }
     resources :team_members
     get 'emails', :to => 'mailer#preview'
     get 'mailer/preview_note'
@@ -28,12 +28,12 @@ Gitlab::Application.routes.draw do
 
   #get "profile/:id", :to => "profile#show"
 
-  resources :projects, :only => [:new, :create, :index]
+  resources :projects, :constraints => { :id => /[^\/]+/ }, :only => [:new, :create, :index]
   resources :keys
 
   devise_for :users
 
-  resources :projects, :except => [:new, :create, :index], :path => "/" do
+  resources :projects, :constraints => { :id => /[^\/]+/ }, :except => [:new, :create, :index], :path => "/" do
     member do
       get "team"
       get "wall"