Permalink
Browse files

Fix route regex so that it can match when there is a trailing slash.

  • Loading branch information...
1 parent f6792af commit 776356c218c0f4c48a3a7b34bc8c7a2c616f32fd @myronmarston myronmarston committed Jun 10, 2013
Showing with 5 additions and 1 deletion.
  1. +1 −1 lib/interpol/endpoint.rb
  2. +4 −0 spec/unit/interpol/endpoint_spec.rb
View
@@ -146,7 +146,7 @@ def route_regex
end
end.join('\/')
- /\A#{regex_string}\z/
+ /\A#{regex_string}\/?\z/
end
end
@@ -158,6 +158,10 @@ def endpoint(route)
expect(endpoint('/foo/bar').route_matches?('/foo/bar')).to be_true
end
+ it 'can match when there is a trailing slash' do
+ expect(endpoint('/foo/bar').route_matches?('/foo/bar/')).to be_true
+ end
+
it 'correctly identifies a non match' do
expect(endpoint('/foo/bar').route_matches?('/goo/bar')).to be_false
end

0 comments on commit 776356c

Please sign in to comment.