meet
meet

Reputation: 1

If I want code to allow all the sub domains what should I do?

Ruby code:

halt 403 unless url.host == 'xyz.webserver.com'

there are many sub domains like xyz. What is the solution if I would like to allow all the sub domains.

Any help would be appreciated.

halt 403 unless url.host == 'xyz.webserver.com'

Upvotes: 0

Views: 35

Answers (2)

tadman
tadman

Reputation: 211690

Another approach is to use case:

case url.host
when /\.webserver\.com\z/i
  halt 403
end

Where that's case-insensitive (/i) and allows you to add other rules as necessary.

Upvotes: 0

infused
infused

Reputation: 24337

One way to do this would be to use String#end_with?

halt 403 unless url.host.end_with?('.webserver.com')

Upvotes: 2

Related Questions