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 domain validation during Client initialization #42

Merged
merged 5 commits into from
Feb 20, 2019

Conversation

sherwinski
Copy link
Contributor

@sherwinski sherwinski commented Feb 20, 2019

Adds a validation that will throw an error if a user attempts to initialize a new Client object with an invalid domain.
The validation criteria is based off of the same regex used on dashboard.imgix.com

Copy link
Contributor

@jayeb jayeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any changes here to rip out the old "magic" behavior of automatically handling protocols and trailing slashes. It looks like that logic is being handled at the end of the get_host method. Can we make sure that gets removed as well?

@@ -75,6 +75,11 @@ def validate_hosts!
unless @hosts.length > 0
raise ArgumentError, "The :host or :hosts option must be specified"
end
@hosts.each do |host|
unless host.match(DOMAIN_REGEX) != nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This double-negative seems unnecessarily confusing. Can we do if host.match(DOMAIN_REGEX) == nil instead?

Copy link
Contributor

@jayeb jayeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 from me once the tests pass

@sherwinski sherwinski merged commit 395825b into master Feb 20, 2019
@sherwinski sherwinski deleted the domain-validation branch February 20, 2019 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants