Skip to content

Commit

Permalink
Allow format to be skipped. This is used internally by mount.
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Aug 24, 2010
1 parent e197d6f commit 80e1f73
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions actionpack/lib/action_dispatch/routing/mapper.rb
Expand Up @@ -87,7 +87,10 @@ def normalize_path(path)
@options.reverse_merge!(:controller => /.+?/)
end

if path.include?(":format")
if @options[:format] == false
@options.delete(:format)
path
elsif path.include?(":format")
path
else
"#{path}(.:format)"
Expand Down Expand Up @@ -244,7 +247,7 @@ def mount(app, options = nil)

raise "A rack application must be specified" unless path

match(path, options.merge(:to => app, :anchor => false))
match(path, options.merge(:to => app, :anchor => false, :format => false))
self
end

Expand Down
2 changes: 1 addition & 1 deletion actionpack/test/dispatch/routing_test.rb
Expand Up @@ -218,7 +218,7 @@ def self.matches?(request)
get "thumbnail" => "avatars#thumbnail", :as => :thumbnail, :on => :member
end
resources :invoices do
get "outstanding" => "invoices#outstanding", :as => :outstanding, :on => :collection
get "outstanding" => "invoices#outstanding", :on => :collection
get "overdue", :to => :overdue, :on => :collection
get "print" => "invoices#print", :as => :print, :on => :member
post "preview" => "invoices#preview", :as => :preview, :on => :new
Expand Down

0 comments on commit 80e1f73

Please sign in to comment.