fix: correctly parse legacy OBSIDIAN_HOST format 'host:port' to avoid double port in URL

This commit is contained in:
2025-08-16 19:04:03 +00:00
parent 00245ef40b
commit 897822ecaa

View File

@@ -84,10 +84,19 @@ class Obsidian():
host = parsed.hostname or '127.0.0.1'
port = parsed.port or (27124 if protocol == 'https' else 27123)
else:
# Legacy hostname/IP only format
protocol = 'https'
host = host_config
port = 27124
# Support legacy formats
# 1) hostname/IP only
# 2) hostname:port (no protocol)
if ':' in host_config:
# Treat as host:port and default protocol to https
parsed = urlparse(f'https://{host_config}')
protocol = 'https'
host = parsed.hostname or '127.0.0.1'
port = parsed.port or 27124
else:
protocol = 'https'
host = host_config
port = 27124
return protocol, host, port