From 59ab8956a92a4482f9c9a214b3b508f85f59d951 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Wed, 23 Sep 2020 10:20:16 +0200 Subject: [PATCH] fix issue when 443 port is used The reason for this issue was that the dart Uri.hasPort[0] property is queried when checking if the passed URL has no port added and thus the implied 8006 port should be added. For https and port 443 the port is detected as "default" and omitted, thus this is always false for that, argh! Just use a simple regex on the original trimmed origin text. IPv6 must be wrapped in brackets so [::1] or [::1]:443 is also correctly detected. [0]: https://api.dart.dev/stable/2.9.1/dart-core/Uri/hasPort.html Signed-off-by: Thomas Lamprecht --- lib/proxmox_login_form.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/proxmox_login_form.dart b/lib/proxmox_login_form.dart index 2a4f501..8ee5c12 100644 --- a/lib/proxmox_login_form.dart +++ b/lib/proxmox_login_form.dart @@ -467,9 +467,12 @@ class _ProxmoxLoginPageState extends State { ..inProgress = true ..message = 'Connection test...'; }); - var apiBaseUrl = Uri.https(_originController.text.trim(), ''); + var host = _originController.text.trim(); + var apiBaseUrl = Uri.https(host, ''); - if (!apiBaseUrl.hasPort) { + RegExp portRE = new RegExp(r":\d{1,5}$"); + + if (!portRE.hasMatch(host)) { _originController.text += ':8006'; apiBaseUrl = apiBaseUrl.replace(port: 8006); } -- 2.39.2