Permalink
Browse files

whois.nic.uk fails to parse registrars without URL (closes GH-188)

  • Loading branch information...
1 parent 3098367 commit 5eb2e30dec2e794585511413e502e80cc164c601 @weppos committed Oct 1, 2012
View
2 CHANGELOG.md
@@ -9,6 +9,8 @@
* FIXED: whois.domainregistry.ie should support status `Active - LOCKED`.
+* FIXED: whois.nic.uk fails to parse registrars without URL (GH-188).
+
## Release 2.7.0
View
36 lib/whois/record/parser/whois.nic.uk.rb
@@ -14,16 +14,11 @@ module Whois
class Record
class Parser
- #
- # = whois.nic.uk parser
- #
# Parser for the whois.nic.uk server.
#
- # NOTE: This parser is just a stub and provides only a few basic methods
- # to check for domain availability and get domain status.
- # Please consider to contribute implementing missing methods.
- # See WhoisNicIt parser for an explanation of all available methods
- # and examples.
+ # @note This parser is just a stub and provides only a few basic methods
+ # to check for domain availability and get domain status.
+ # Please consider to contribute implementing missing methods.
#
# @see http://www.nominet.org.uk/other/whois/detailedinstruct/
#
@@ -88,23 +83,26 @@ class WhoisNicUk < Base
# @see http://www.nic.uk/other/whois/instruct/
property_supported :registrar do
- if content_for_scanner =~ /Registrar:\n(.+) \[Tag = (.+)\]\n\s*URL: (.+)\n/
- name, id, url = $1.strip, $2.strip, $3.strip
- org, name = name.split(" t/a ")
+ if content_for_scanner =~ /Registrar:\n((.+\n)+)\n/
+ content = $1.strip
+ id = name = org = url = nil
+
+ if content =~ /Tag =/
+ name, id = (content =~ /(.+) \[Tag = (.+)\]/) && [$1.strip, $2.strip]
+ org, name = name.split(" t/a ")
+ url = (content =~ /URL: (.+)/) && $1.strip
+ elsif content =~ /This domain is registered directly with Nominet/
+ name = "Nominet"
+ org = "Nominet UK"
+ url = "http://www.nic.uk/"
+ end
Record::Registrar.new(
:id => id,
- :name => (name || org),
+ :name => name || org,
:organization => org,
:url => url
)
- elsif content_for_scanner =~ /This domain is registered directly with Nominet/
- Record::Registrar.new(
- :id => nil,
- :name => "Nominet",
- :organization => "Nominet UK",
- :url => "http://www.nic.uk/"
- )
end
end
View
6 spec/fixtures/responses/whois.nic.uk/property_registrar_godaddy.expected
@@ -0,0 +1,6 @@
+#registrar
+ should: %s CLASS(registrar)
+ should: %s.id == "GODADDY"
+ should: %s.name == "GoDaddy.com, LLP."
+ should: %s.name == "GoDaddy.com, LLP."
+ should: %s.url == nil
View
47 spec/fixtures/responses/whois.nic.uk/property_registrar_godaddy.txt
@@ -0,0 +1,47 @@
+
+ Domain name:
+ ecigsbrand.co.uk
+
+ Registrant:
+ Vitality & Wellness Ltd.
+
+ Registrant type:
+ Unknown
+
+ Registrant's address:
+ 72 High Street
+ Haslemere
+ Surrey
+ GU27 2LA
+ United Kingdom
+
+ Registrar:
+ GoDaddy.com, LLP. [Tag = GODADDY]
+
+ Relevant dates:
+ Registered on: 16-Sep-2010
+ Expiry date: 16-Sep-2013
+ Last updated: 30-Aug-2012
+
+ Registration status:
+ Registered until expiry date.
+
+ Name servers:
+ pdns01.domaincontrol.com
+ pdns02.domaincontrol.com
+
+ WHOIS lookup made at 13:23:18 01-Oct-2012
+
+--
+This WHOIS information is provided for free by Nominet UK the central registry
+for .uk domain names. This information and the .uk WHOIS are:
+
+ Copyright Nominet UK 1996 - 2012.
+
+You may not access the .uk WHOIS or use any data from it except as permitted
+by the terms of use available in full at http://www.nominet.org.uk/whois, which
+includes restrictions on: (A) use of the data for advertising, or its
+repackaging, recompilation, redistribution or reuse (B) obscuring, removing
+or hiding any or all of this notice and (C) exceeding query rate or volume
+limits. The data is provided on an 'as-is' basis and may lag behind the
+register. Access may be withdrawn or restricted at any time.
View
33 spec/whois/record/parser/responses/whois.nic.uk/property_registrar_godaddy_spec.rb
@@ -0,0 +1,33 @@
+# encoding: utf-8
+
+# This file is autogenerated. Do not edit it manually.
+# If you want change the content of this file, edit
+#
+# /spec/fixtures/responses/whois.nic.uk/property_registrar_godaddy.expected
+#
+# and regenerate the tests with the following rake task
+#
+# $ rake spec:generate
+#
+
+require 'spec_helper'
+require 'whois/record/parser/whois.nic.uk.rb'
+
+describe Whois::Record::Parser::WhoisNicUk, "property_registrar_godaddy.expected" do
+
+ subject do
+ file = fixture("responses", "whois.nic.uk/property_registrar_godaddy.txt")
+ part = Whois::Record::Part.new(:body => File.read(file))
+ described_class.new(part)
+ end
+
+ describe "#registrar" do
+ it do
+ subject.registrar.should be_a(Whois::Record::Registrar)
+ subject.registrar.id.should == "GODADDY"
+ subject.registrar.name.should == "GoDaddy.com, LLP."
+ subject.registrar.name.should == "GoDaddy.com, LLP."
+ subject.registrar.url.should == nil
+ end
+ end
+end

0 comments on commit 5eb2e30

Please sign in to comment.