]> git.proxmox.com Git - flutter/proxmox_login_manager.git/commitdiff
fix issue when 443 port is used
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 23 Sep 2020 08:20:16 +0000 (10:20 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 23 Sep 2020 08:20:19 +0000 (10:20 +0200)
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 <t.lamprecht@proxmox.com>
lib/proxmox_login_form.dart

index 2a4f5011279944ca508aeb69ed11f5d3d6a4ae36..8ee5c123c277f81b8213faca090f30dfa4710b43 100644 (file)
@@ -467,9 +467,12 @@ class _ProxmoxLoginPageState extends State<ProxmoxLoginPage> {
         ..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);
     }