0
0
Fork 0

allow a dash in the middle url part

This commit is contained in:
Gibheer 2013-09-10 08:56:24 +02:00
parent defb7703c6
commit 3e0a3f20a7
2 changed files with 14 additions and 1 deletions

View File

@ -20,7 +20,7 @@ module Zero
# 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

View File

@ -103,4 +103,17 @@ describe Zero::Router, '#call' do
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