introduce Wallet.normalize_endpoint to remove code duplication

This commit is contained in:
Pavol Rusnak
2024-01-22 10:06:22 -06:00
parent 824a8fa7c8
commit 8eabf53642
12 changed files with 25 additions and 27 deletions
+8
View File
@@ -95,6 +95,14 @@ class Wallet(ABC):
def paid_invoices_stream(self) -> AsyncGenerator[str, None]:
pass
def normalize_endpoint(self, endpoint: str, add_proto=True) -> str:
endpoint = endpoint[:-1] if endpoint.endswith("/") else endpoint
if add_proto:
endpoint = (
f"https://{endpoint}" if not endpoint.startswith("http") else endpoint
)
return endpoint
class Unsupported(Exception):
pass