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

Add .flatten to location_allow to enable using nested arrays #1420

Merged
merged 2 commits into from
Oct 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion spec/defines/resource_location_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,25 @@
match: ' expires 33d;'
},
{
title: 'should set location_allow',
title: 'should set location_allow (flat array)',
attr: 'location_allow',
value: %w[127.0.0.1 10.0.0.1],
match: [
' allow 127.0.0.1;',
' allow 10.0.0.1;'
]
},
{
title: 'should set location_allow (nested array)',
attr: 'location_allow',
value: %w[127.0.0.1 10.0.0.1 [127.0.0.2 10.0.0.2]],
match: [
' allow 127.0.0.1;',
' allow 10.0.0.1;'
' allow 127.0.0.2;',
' allow 10.0.0.2;'
]
},
{
title: 'should set location_deny',
attr: 'location_deny',
Expand Down
2 changes: 1 addition & 1 deletion templates/server/location_header.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
expires <%= @expires %>;
<% end -%>
<% if @location_allow -%>
<%- @location_allow.each do |allow_rule| -%>
<%- @location_allow.flatten.each do |allow_rule| -%>
allow <%= allow_rule %>;
<%- end -%>
<% end -%>
Expand Down