1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

net.urllib: workaround an autofree bug for if cond && opt() {

This commit is contained in:
Delyan Angelov 2021-01-12 16:28:59 +02:00
parent 4ffe3d83b8
commit ef18fb837c
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED

View File

@ -997,9 +997,11 @@ fn split_host_port(hostport string) (string, string) {
mut host := hostport mut host := hostport
mut port := '' mut port := ''
colon := host.last_index_byte(`:`) colon := host.last_index_byte(`:`)
if colon != -1 && valid_optional_port(host[colon..]) { if colon != -1 {
port = host[colon + 1..] if valid_optional_port(host[colon..]) {
host = host[..colon] port = host[colon + 1..]
host = host[..colon]
}
} }
if host.starts_with('[') && host.ends_with(']') { if host.starts_with('[') && host.ends_with(']') {
host = host[1..host.len - 1] host = host[1..host.len - 1]