lib/imgix/client.rb in imgix-1.2.2 vs lib/imgix/client.rb in imgix-2.0.0
- old
+ new
@@ -47,11 +47,11 @@
end
def get_host(path)
host = host_for_crc(path) if @shard_strategy == :crc
host = host_for_cycle if @shard_strategy == :cycle
- host.gsub("http://","").gsub("https://","").chomp("/")
+ host
end
def host_for_crc(path)
crc = Zlib.crc32(path)
index = crc % @hosts.length - 1
@@ -72,9 +72,14 @@
end
def validate_hosts!
unless @hosts.length > 0
raise ArgumentError, "The :host or :hosts option must be specified"
+ end
+ @hosts.each do |host|
+ if host.match(DOMAIN_REGEX) == nil
+ raise ArgumentError, "Domains must be passed in as fully-qualified domain names and should not include a protocol or any path element, i.e. \"example.imgix.net\"."
+ end
end
end
end
end