-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nested namespace with optional url parts do not work in sinatra => 2.0 #1361
Comments
So I dug a little deeper but have a hard time pinpointing the issue. I did find another unexpected behavior that might be related: mock_app do
namespace '/foo/:year/?:period?' do
before do
puts "Period in before: '#{params[:period]}'"
end
namespace '/nested' do
get '/1' do
puts "Period in get: '#{params[:period]}'"
200
end
end
end
end If you call this with
I don't think this is correct, I expect a parameter in a single call to remain the same. |
Another update: So when I remove the generating of the |
Definitely bug, but it's not Sinatra issue, but Mustermann issue. p Mustermann.new("/foo/:year/?:period?") + Mustermann.new("/nested") + Mustermann.new(%r{(?:/.*)?})
p Mustermann.new("/foo/:year/?:period?") + (Mustermann.new("/nested") + Mustermann.new(%r{(?:/.*)?})) |
So I'm going to fix the issue as a mustermann's problem. |
The meaning of the following two expressions is different, but it's unexpected behavior. Mustermann.new("/a") + Mustermann.new("/b") + Mustermann.new(/c/) Mustermann.new("/a") + (Mustermann.new("/b") + Mustermann.new(/c/)) The differencet leads to occur a bug on sinatra-namespace. This commit fixes sinatra/sinatra#1361
@lvonk Could you confirm my changes? The problem can be resolved in my locally. mock_app do
namespace '/foo/:year/?:period?' do
namespace '/nested' do
helpers do
def foo
"foo"
end
end
get('/1') { foo }
end
end
end
get '/foo/2018/2/nested/1'
expect(last_response.body).to eq('foo')
get '/foo/2018/nested/1'
expect(last_response.body).to eq('foo') You can specify my branch in your Gemfile, it would be something like: gem 'mustermann', github: 'namusyaka/mustermann', branch: 'native-concat-look-ahead-parts' |
Thanks @namusyaka ! I can confirm the testcase now works in my example. |
The meaning of the following two expressions is different, but it's unexpected behavior. Mustermann.new("/a") + Mustermann.new("/b") + Mustermann.new(/c/) Mustermann.new("/a") + (Mustermann.new("/b") + Mustermann.new(/c/)) The differencet leads to occur a bug on sinatra-namespace. This commit fixes sinatra/sinatra#1361
I have just released mustermann-1.0.2.rc1. |
Sorry, the mustermann-1.0.2.rc1 is not correct. I re-released mustermann-1.0.2.rc2. |
Closing. mustermann-1.0.2 is out. |
I can confirm this works in |
@lvonk Thank you ❤️ |
* **Mustermann 1.0.2** (2017-02-17) * Look ahead same patterns as its own when concatenation. Fixes [sinatra/sinatra#1361](sinatra/sinatra#1361) [@namusyaka](https://github.com/namusyaka) * Improve development support and documentation. [@EdwardBetts](https://github.com/EdwardBetts), [@284km](https://github.com/284km), [@yb66](https://github.com/yb66) and [@garybernhardt](https://github.com/garybernhardt)
Hi,
I have the following app (which worked in sinatra < 2.0):
When I call
/foo/2018/2/nested/1
all works as expected. When I call/foo/2018/nested/1
it results in aDuplicating the outer namespace "resolves" the issue:
Full test case can be found here: https://github.com/lvonk/sinatra-namespaces-issue
The text was updated successfully, but these errors were encountered: