fix(shared): fix missing port in public_url

This commit is contained in:
jo 2022-02-22 18:40:46 +01:00 committed by Kyle Robbertze
parent f24996e144
commit ba0897a023
1 changed files with 8 additions and 3 deletions

View File

@ -105,7 +105,7 @@ class GeneralConfig(BaseModel):
protocol: str = "http"
base_url: str = "localhost"
base_port: int = 80
base_port: Optional[int]
base_dir: str = "/"
force_ssl: bool = False
@ -113,8 +113,13 @@ class GeneralConfig(BaseModel):
def public_url(self) -> str:
scheme = "https" if self.force_ssl else self.protocol
url = urlunsplit((scheme, self.base_url, self.base_dir, None, None))
return url.rstrip("/")
location = self.base_url
if self.base_port is not None:
location += f":{self.base_port}"
path = self.base_dir.rstrip("/")
return urlunsplit((scheme, location, path, None, None))
# pylint: disable=too-few-public-methods