allow a dash in the middle url part
This commit is contained in:
parent
defb7703c6
commit
3e0a3f20a7
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue