Skip to content
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

avoid prefix duplication #1322

Merged
merged 2 commits into from
Aug 21, 2017
Merged

avoid prefix duplication #1322

merged 2 commits into from
Aug 21, 2017

Conversation

namusyaka
Copy link
Member

Fixes #1310
@aren55555 @mencargo @zzak Could you confirm this?

@aren55555
Copy link

aren55555 commented Jul 5, 2017

Looks like this branch works. LGTM.

Gemfile:

github 'namusyaka/sinatra', branch: 'fix-1310' do
  gem 'sinatra'
  gem 'sinatra-contrib'
end

app.rb:

require 'rubygems'
require 'bundler/setup'
require 'sinatra'
require 'sinatra/contrib'
require 'json'

BOOKS = {
  1 => {name: 'The Lord of the Rings'},
  2 => {name: 'The Chronicles of Narnia'},
  3 => {name: 'Harry Potter'},
}

namespace '/api' do
  namespace '/v1' do
    namespace '/books' do
      get do
        body JSON.dump(BOOKS)
      end
    end
  end
end

Curl:

curl -X GET http://localhost:4567/api/v1/books

Curl resp:

{"1":{"name":"The Lord of the Rings"},"2":{"name":"The Chronicles of Narnia"},"3":{"name":"Harry Potter"}}

@@ -319,7 +319,6 @@ def compile(pattern, conditions, default_pattern = nil)
end
base_pattern, base_conditions = @pattern, @conditions
pattern ||= default_pattern
base_pattern ||= base.pattern if base.respond_to? :pattern
base_conditions ||= base.conditions if base.respond_to? :conditions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this case, don't we also set base_conditions above too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes. However, it should be treated as a different issue.
Briefly, that conditions has not been permanently satisfied, so I deleted it as new commit.

the `base` does not respond to `conditions` permanently.
@zzak zzak merged commit 59320a8 into sinatra:master Aug 21, 2017
@namusyaka namusyaka deleted the fix-1310 branch September 3, 2017 07:15
@olleolleolle olleolleolle mentioned this pull request Sep 5, 2017
@namusyaka namusyaka added this to the v2.0.1 milestone Feb 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants