Added better uri parsing, updated README
This commit is contained in:
parent
c00aa232fc
commit
5628e4f062
2 changed files with 36 additions and 3 deletions
dockge_cli/client/commands
|
@ -1,5 +1,6 @@
|
|||
from urllib.parse import urlparse
|
||||
from getpass import getpass
|
||||
import re
|
||||
|
||||
from ...models import Credentials
|
||||
from ...service import storage
|
||||
|
@ -26,10 +27,12 @@ class FunctionBindings():
|
|||
host command binding
|
||||
"""
|
||||
if len(extra_args) > 0:
|
||||
res = urlparse(extra_args[0])
|
||||
mat = re.search(r"((\w+\.)?\w+\.\w+(\/.+)?)", extra_args[0], re.IGNORECASE)
|
||||
if mat is None:
|
||||
raise ValueError("Given host did not match regex")
|
||||
res = urlparse(f"https://{mat[0]}")
|
||||
if all([res.scheme, res.netloc]):
|
||||
host = extra_args[0].rstrip("/").replace("https://", "").replace("wss://", "")
|
||||
storage.put("host", host)
|
||||
storage.put("host", mat[0])
|
||||
else:
|
||||
raise ValueError(f"Malformed URL {extra_args[0]}")
|
||||
print(storage.get("host"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue