Skip to content

Commit

Permalink
Fix multiple origin config logic
Browse files Browse the repository at this point in the history
Accidentally removed logic that supports multiple configurations
with the same origin
  • Loading branch information
cyu committed Oct 19, 2014
1 parent 7ee8ac2 commit 3314573
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/rack/cors.rb
Expand Up @@ -132,13 +132,17 @@ def process_cors(env)
end

def find_resource(origin, path, env)
match = all_resources.detect { |r| r.allow_origin?(origin, env) }
return [nil, 'no-origin-match'] unless match

found = match.find_resource(path)
return [nil, 'no-path-match'] unless found
origin_matched = false
all_resources.each do |r|
if r.allow_origin?(origin, env)
origin_matched = true
if found = r.find_resource(path)
return [found, nil]
end
end
end

[found, nil]
[nil, origin_matched ? 'no-path-match' : 'no-origin-match']
end

class Resources
Expand Down

0 comments on commit 3314573

Please sign in to comment.