-
Notifications
You must be signed in to change notification settings - Fork 122
Allow regexp for a allowed_request_origins array #130
Conversation
@@ -180,6 +180,11 @@ def allow_request_origin? | |||
end | |||
end | |||
|
|||
def allowed_origins_match? origin | |||
allowed_origins = Array(server.config.allowed_request_origins) | |||
allowed_origins.any? { |allowed_origin| allowed_origin.is_a?(Regexp) ? allowed_origin =~ origin : allowed_origin == origin } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use the ===
operator to match both strings and regexes, so the class check wouldn't be required.
allowed_origins.any? { |allowed_origin| allowed_origin === origin }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, given this, we don't need the extra method. We can just inline this === check like we had the original include call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, that makes sense. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adamliesko I don't think this method is used anymore and can be removed.
4687f06
to
0bbeba3
Compare
@adamliesko Do you want to wrap up these changes? Then we can merge. |
54b8dcf
to
09e10ef
Compare
@dhh I have updated the |
Allow regexp for a allowed_request_origins array
👏 |
Adding the feature of additional regexp check for
allowed_origin_requests
instead of only strict equal comparation.Fixes #130