From ef97185eeedcb85fe27a06c42ffc29184bbab85f Mon Sep 17 00:00:00 2001 From: Brian Greunke Date: Wed, 30 Apr 2025 14:21:41 -0500 Subject: [PATCH] feat(configure): add automatic HTTPS scheme for server URLs without scheme If server URL is provided without a scheme, it will automatically be prefixed with HTTPS. This improves usability by letting users enter just the domain name while maintaining secure connections. --- dreadnode/main.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dreadnode/main.py b/dreadnode/main.py index d3773e70..ea3169a8 100644 --- a/dreadnode/main.py +++ b/dreadnode/main.py @@ -7,7 +7,7 @@ from dataclasses import dataclass from datetime import datetime, timezone from pathlib import Path -from urllib.parse import urljoin +from urllib.parse import urljoin, urlparse, urlunparse import coolname # type: ignore [import-untyped] import logfire @@ -205,6 +205,16 @@ def initialize(self) -> None: category=DreadnodeConfigWarning, ) + if self.server: + parsed_url = urlparse(self.server) + if not parsed_url.scheme: + netloc = parsed_url.path.split("/")[0] + path = "/".join(parsed_url.path.split("/")[1:]) + parsed_new = parsed_url._replace( + scheme="https", netloc=netloc, path=f"/{path}" if path else "" + ) + self.server = urlunparse(parsed_new) + if self.local_dir is not False: config = FileExportConfig( base_path=self.local_dir,