Skip to content

Commit c1b61e9

Browse files
committed
Simplify the logic in _require.erb
If we take the expression: !(_item['require'] && _item['require'] != '') && _item['require'] !~ /unmanaged/i && !(_item['auth_require']) This is hard to read, but equal to: (!_item['require'] || _item['require'] == '') && _item['require'] !~ /unmanaged/i && !(_item['auth_require']) This makes it easier to see that item must be `nil` or `''`. Those will never match `/unmanaged/i` so it can be simplified to: (!_item['require'] || _item['require'] == '') && !(_item['auth_require']) Just before it is a block that already checks the last section, so it can be reduced to an elsif on that block.
1 parent ce06491 commit c1b61e9

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

templates/vhost/_require.erb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
<%- end -%>
2121
<%- if _item['auth_require'] -%>
2222
Require <%= _item['auth_require'] %>
23-
<%- end -%>
24-
<%- if !(_item['require'] && _item['require'] != '') && _item['require'] !~ /unmanaged/i && !(_item['auth_require']) -%>
23+
<%- elsif !_item['require'] || _item['require'] == '' -%>
2524
Require all granted
2625
<%- end -%>
2726
<%- else -%>

0 commit comments

Comments
 (0)