Permalink
Browse files

allow a dash in the middle url part

  • Loading branch information...
1 parent defb770 commit 3e0a3f20a79330f1f152a5f3667b29cb904d959c @Gibheer Gibheer committed Sep 10, 2013
Showing with 14 additions and 1 deletion.
  1. +1 −1 lib/zero/router.rb
  2. +13 −0 spec/unit/zero/router/call_spec.rb
View
@@ -20,7 +20,7 @@ class Router
# match for variables in routes
VARIABLE_MATCH = %r{:(\w+)[^/]?}
# the replacement string to make it an regex
- VARIABLE_REGEX = '(?<\1>[\w]+?)'
+ VARIABLE_REGEX = '(?<\1>[\w-]+?)'
# regex part of the beginning of the line
REGEX_BEGINNING = '\A'
# regex part of the end of the line
@@ -103,4 +103,17 @@
it_behaves_like "a sample app"
end
+
+ context 'with a dash in the variable' do
+ let(:routes) { {'/:id' => app} }
+ let(:env) { EnvGenerator.get('/foo-bar') }
+ let(:app) do
+ lambda do |env|
+ [200, content_type, [Zero::Request.new(env).params['id']]]
+ end
+ end
+ let(:result) { ['foo-bar'] }
+
+ it_behaves_like "a sample app"
+ end
end

0 comments on commit 3e0a3f2

Please sign in to comment.