Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Normalize request_method string.

  • Loading branch information...
commit 333cb7a24bdc131b8e863ce4d1b06fc44bf6a45c 1 parent 3b38d70
@mynyml authored
Showing with 13 additions and 2 deletions.
  1. +2 −2 Rakefile
  2. +2 −0  lib/simple_router/routes.rb
  3. +9 −0 test/test_routes.rb
View
4 Rakefile
@@ -23,8 +23,8 @@ end
spec = Gem::Specification.new do |s|
s.name = 'simple_router'
s.version = '0.8'
- s.summary = "Minimalistic, simple router meant to be used with pure rack applications."
- s.description = "Minimalistic, simple router meant to be used with pure rack applications."
+ s.summary = "Simple, minimalistic router meant to be used with pure rack applications."
+ s.description = "Simple, minimalistic router meant to be used with pure rack applications."
s.author = "Martin Aumont"
s.email = 'mynyml@gmail.com'
s.homepage = ''
View
2  lib/simple_router/routes.rb
@@ -16,6 +16,8 @@ def match(verb, path)
none = [nil, nil]
return none if self.empty?
+ verb = verb.to_s.downcase.strip.to_sym
+
routes = self.select {|route| route.verb == verb }
paths = routes.map {|route| route.path }
View
9 test/test_routes.rb
@@ -31,6 +31,15 @@ def setup
@routes.match('/baz', :get).should be([nil,nil])
end
+ test "normalizes passed in verb string" do
+ @routes.add(:get, '/foo', {}, &@action)
+ @routes.add(:get, '/bar', {}, &@action)
+
+ @routes.match('get', '/bar').first.path.should be('/bar')
+ @routes.match('GET', '/bar').first.path.should be('/bar')
+ @routes.match(' GET ','/bar').first.path.should be('/bar')
+ end
+
## engine
test "default engine" do
Please sign in to comment.
Something went wrong with that request. Please try again.