Skip to content

Commit

Permalink
Merge pull request #1420 from kBite/add-flatten
Browse files Browse the repository at this point in the history
Add `.flatten` to `location_allow` to enable using nested arrays
  • Loading branch information
kengelhardt-godaddy committed Oct 30, 2020
2 parents 36b5610 + 5f03f1d commit 0e52448
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
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

0 comments on commit 0e52448

Please sign in to comment.