From: Maxim Vladimirsky Date: Fri, 7 Mar 2014 21:26:27 +0000 (-0800) Subject: Fix exception in UrlAddress.hostname for local URLs X-Git-Tag: v0.3.12~1^2~1^2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=177f16557cb094002d8af59588e65312333dbfd1;p=flanker.git Fix exception in UrlAddress.hostname for local URLs --- diff --git a/flanker/addresslib/address.py b/flanker/addresslib/address.py index 9aeb70a..7b5adc2 100644 --- a/flanker/addresslib/address.py +++ b/flanker/addresslib/address.py @@ -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): diff --git a/tests/addresslib/address_test.py b/tests/addresslib/address_test.py index 4652faa..6a8ef13 100644 --- a/tests/addresslib/address_test.py +++ b/tests/addresslib/address_test.py @@ -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))