Skip to content

Commit

Permalink
Merge pull request #31 from floscha/schemeless-url
Browse files Browse the repository at this point in the history
Accept URLs without scheme (also includes #18 and #28)
  • Loading branch information
dvf authored Jan 26, 2018
2 parents 6650862 + 7603173 commit 250a01c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ def register_node(self, address):
"""

parsed_url = urlparse(address)
self.nodes.add(parsed_url.netloc)
if parsed_url.netloc:
self.nodes.add(parsed_url.netloc)
elif parsed_url.path:
# Accepts an URL without scheme like '192.168.0.5:5000'.
self.nodes.add(parsed_url.path)
else:
raise ValueError('Invalid URL')


def valid_chain(self, chain):
"""
Expand Down

0 comments on commit 250a01c

Please sign in to comment.