From ef18fb837ce45c4f8a3c9572b64be77c86193a93 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Tue, 12 Jan 2021 16:28:59 +0200 Subject: [PATCH] net.urllib: workaround an autofree bug for `if cond && opt() {` --- vlib/net/urllib/urllib.v | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/vlib/net/urllib/urllib.v b/vlib/net/urllib/urllib.v index d5a74e76b1..6aba9189f6 100644 --- a/vlib/net/urllib/urllib.v +++ b/vlib/net/urllib/urllib.v @@ -997,9 +997,11 @@ fn split_host_port(hostport string) (string, string) { mut host := hostport mut port := '' colon := host.last_index_byte(`:`) - if colon != -1 && valid_optional_port(host[colon..]) { - port = host[colon + 1..] - host = host[..colon] + if colon != -1 { + if valid_optional_port(host[colon..]) { + port = host[colon + 1..] + host = host[..colon] + } } if host.starts_with('[') && host.ends_with(']') { host = host[1..host.len - 1]