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
|
# match for variables in routes
|
||||||
VARIABLE_MATCH = %r{:(\w+)[^/]?}
|
VARIABLE_MATCH = %r{:(\w+)[^/]?}
|
||||||
# the replacement string to make it an regex
|
# 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 part of the beginning of the line
|
||||||
REGEX_BEGINNING = '\A'
|
REGEX_BEGINNING = '\A'
|
||||||
# regex part of the end of the line
|
# regex part of the end of the line
|
||||||
|
|
|
@ -103,4 +103,17 @@ describe Zero::Router, '#call' do
|
||||||
|
|
||||||
it_behaves_like "a sample app"
|
it_behaves_like "a sample app"
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in New Issue