Skip to content

Commit

Permalink
Change regexp of RouteSet's conditions[:request_method]
Browse files Browse the repository at this point in the history
RFC2616 defines Request-Line which includes method token
is separated by SP characters.
So we should not match it with multiline anchors.

cf: http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1
  • Loading branch information
yui-knk committed Oct 3, 2015
1 parent dd57f60 commit b8b745d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/journey/route.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def requires_matching_verb?
end

def verb
%r[^#{verbs.join('|')}$]
%r[\A#{verbs.join('|')}\Z]
end

private
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/routing/inspector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def rack_app
end

def verb
super.source.gsub(/[$^]/, '')
super.source.gsub(/\\A|\\Z/, '')
end

def path
Expand Down
4 changes: 2 additions & 2 deletions actionpack/test/dispatch/mapper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def test_random_keys
end
assert_equal({:omg=>:awesome, :controller=>"posts", :action=>"index"},
fakeset.defaults.first)
assert_equal(/^GET$/, fakeset.routes.first.verb)
assert_equal(/\AGET\Z/, fakeset.routes.first.verb)
end

def test_mapping_requirements
Expand All @@ -99,7 +99,7 @@ def test_via_scope
mapper.scope(via: :put) do
mapper.match '/', :to => 'posts#index', :as => :main
end
assert_equal(/^PUT$/, fakeset.routes.first.verb)
assert_equal(/\APUT\Z/, fakeset.routes.first.verb)
end

def test_map_slash
Expand Down

0 comments on commit b8b745d

Please sign in to comment.