]> khamidou — GitHub mirrors - flanker.git/commitdiff
Fix exception in UrlAddress.hostname for local URLs
authorMaxim Vladimirsky <horkhe@gmail.com>
Fri, 7 Mar 2014 21:26:27 +0000 (13:26 -0800)
committerMaxim Vladimirsky <horkhe@gmail.com>
Fri, 7 Mar 2014 21:26:27 +0000 (13:26 -0800)
flanker/addresslib/address.py
tests/addresslib/address_test.py

index 9aeb70a37332db02e20c858a37b6246452760175..7b5adc2d885a5d892a715a750beb481ed1a0555d 100644 (file)
@@ -471,7 +471,9 @@ class UrlAddress(Address):
 
     @property
     def hostname(self):
-        return self.parse_result.hostname.lower()
+        hostname = self.parse_result.hostname
+        if hostname:
+            return hostname.lower()
 
     @property
     def port(self):
index 4652faae05da4f533299b2e6d52627c9e1a74762..6a8ef13d7af86094e61b26090e8b19e894f6e7d9 100644 (file)
@@ -47,6 +47,11 @@ def test_address_compare():
     eq_ (2, len(s))
 
 
+def test_local_url():
+    u = UrlAddress('http:///foo/bar')
+    eq_(None, u.hostname)
+
+
 def test_addresslist_basics():
     lst = parse_list("http://foo.com:1000; Biz@Kontsevoy.Com   ")
     eq_ (2, len(lst))