Skip to content

Commit

Permalink
fixed error when domain is nil
Browse files Browse the repository at this point in the history
  • Loading branch information
mmriis committed Oct 24, 2011
1 parent 6d7c432 commit a370399
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/simpleidn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ def encode(input)
# SimpleIDN.to_ascii("møllerriis.com")
# => "xn--mllerriis-l8a.com"
def to_ascii(domain)
return if domain.nil?
domain_array = domain.split(".")
out = []
i = 0
Expand All @@ -239,6 +240,7 @@ def to_ascii(domain)
# SimpleIDN.to_unicode("xn--mllerriis-l8a.com")
# => "møllerriis.com"
def to_unicode(domain)
return if domain.nil?
domain_array = domain.split(".")
out = []
i = 0
Expand Down
11 changes: 11 additions & 0 deletions spec/idn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@
it "should respect * and not try to decode it" do
SimpleIDN.to_unicode("*.xn--mllerriis-l8a.com").should == "*.møllerriis.com"
end

it "should return nil for nil" do
SimpleIDN.to_unicode(nil).should be_nil
end

end

describe "to_ascii" do
it "should pass all test cases" do
TESTCASES_JOSEFSSON.sort.each do |testcase, vector|
Expand All @@ -25,5 +31,10 @@
it "should respect * and not try to encode it" do
SimpleIDN.to_ascii("*.hello.com").should == "*.hello.com"
end


it "should return nil for nil" do
SimpleIDN.to_ascii(nil).should be_nil
end
end
end

0 comments on commit a370399

Please sign in to comment.