fix url parsing

This commit is contained in:
Hedy Li 2021-07-19 09:55:56 +08:00
parent 59faffbac9
commit f8dcf4642c
Signed by: hedy
GPG Key ID: B51B5A8D1B176372
2 changed files with 5 additions and 1 deletions

View File

@ -1,6 +1,6 @@
[tool.poetry]
name = "spartan-py"
version = "0.2.5"
version = "0.2.6"
description = "Library for spartan protocol"
authors = ["Hedy Li <hedy@tilde.cafe>"]
packages = [

View File

@ -68,6 +68,10 @@ class Status:
def get(url: str, data: str = ""):
"""Fetches url and returns a response object"""
u = urllib.parse.urlparse(url)
if not u.hostname:
u = urllib.parse.urlparse("spartan://"+url)
if u.scheme != "spartan":
raise RuntimeError("Unsupported scheme")
if u.query: # Ignores data argument if query is in url
data = u.query
req = Request(u.hostname, u.port or 300, u.path or "/", data)