Fixed a bug in the webfinger code

This commit is contained in:
Roland Hedberg 2013-09-12 09:09:40 +02:00
parent 864cd56921
commit 66646627f9
2 changed files with 3 additions and 4 deletions

View File

@ -230,8 +230,8 @@ class WebFinger(object):
if resource.startswith("http"):
part = urlparse.urlparse(resource)
host = part.hostname
if part.port:
host = "%s:%s" % (host, part.port)
if part.port is not None:
host += ":" + str(part.port)
elif resource.startswith("acct:"):
host = resource.split('@')[-1]
host = host.replace('/', '#').replace('?', '#').split("#")[0]
@ -279,7 +279,7 @@ class WebFinger(object):
return link["href"]
return None
elif rsp.status_code in [302, 301, 307]:
return self.discovery_query(rsp.headers["location"], resource)
return self.discovery_query(rsp.headers["location"])
else:
raise Exception(rsp.status_code)

View File

@ -74,7 +74,6 @@ def test_wf0():
assert query == 'https://p1.example.com/.well-known/webfinger?resource=device%3Ap1.example.com'
def test_wf1():
wf = WebFinger()
query = wf.query("acct:bob@example.com",