Permalink
Browse files

check domain name for ascii chars

there is no IDN support for .AZ domains
  • Loading branch information...
1 parent 37216d3 commit 1cccbd79edb9c8452e75ae2c450dd17d3b13796a @NARKOZ committed Mar 17, 2012
Showing with 5 additions and 0 deletions.
  1. +2 −0 .rspec
  2. +1 −0 lib/whoaz.rb
  3. +2 −0 spec/whoaz/whois_spec.rb
View
@@ -0,0 +1,2 @@
+--color
+--format d
View
@@ -14,6 +14,7 @@ module Whoaz
def self.whois(domain='')
domain = domain.to_s.strip.downcase
raise EmptyDomain, "Domain not specified" if domain.empty?
+ raise InvalidDomain, "Domain contains non-ASCII characters" unless domain.ascii_only?
Whoaz::Whois.new(domain)
end
end
@@ -1,3 +1,4 @@
+# encoding: utf-8
require 'spec_helper'
describe Whoaz::Whois do
@@ -13,6 +14,7 @@
it "should raise InvalidDomain" do
expect { Whoaz.whois 'google' }.to raise_error Whoaz::InvalidDomain, 'Invalid domain specified'
expect { Whoaz.whois 'goo.gl' }.to raise_error Whoaz::InvalidDomain, 'Invalid domain specified'
+ expect { Whoaz.whois 'алм.az' }.to raise_error Whoaz::InvalidDomain, 'Domain contains non-ASCII characters'
end
end

0 comments on commit 1cccbd7

Please sign in to comment.