Skip to content

Commit

Permalink
Fix #1205 -- Allow Regexp routes to use :provides option.
Browse files Browse the repository at this point in the history
  • Loading branch information
shipstar committed Apr 5, 2013
1 parent 0dd67e0 commit 9b048b1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
8 changes: 7 additions & 1 deletion padrino-core/lib/padrino-core/application/routing.rb
Expand Up @@ -90,7 +90,13 @@ def custom_conditions(&block)
end

def significant_variable_names
@significant_variable_names ||= @original_path.nil? ? [] : @original_path.scan(/(^|[^\\])[:\*]([a-zA-Z0-9_]+)/).map{|p| p.last.to_sym}
@significant_variable_names ||= if @original_path.is_a?(String)
@original_path.scan(/(^|[^\\])[:\*]([a-zA-Z0-9_]+)/).map{|p| p.last.to_sym}
elsif @original_path.is_a?(Regexp) and @original_path.respond_to?(:named_captures)
@original_path.named_captures.keys.map(&:to_sym)
else
[]
end
end
end

Expand Down
8 changes: 8 additions & 0 deletions padrino-core/test/test_routing.rb
Expand Up @@ -207,6 +207,14 @@ class FooError < RuntimeError; end
assert_equal 404, status
end

should 'allow regex url with format' do
mock_app do
get(/.*/, :provides => :any) { "regexp" }
end
get "/anything"
assert_equal "regexp", body
end

should 'use padrino url method' do
mock_app do
end
Expand Down

0 comments on commit 9b048b1

Please sign in to comment.