Skip to content

Commit

Permalink
fix merge
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Sep 29, 2024
1 parent 7c54c5a commit 88feb47
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions vlib/net/util.v
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,24 @@ pub fn split_address(addr string) !(string, u16) {
port := addr.all_after_last(']:').int()
p := validate_port(port)!
return address, p
} else if _ := addr.index(':') {
// ipv6 ::1
if addr.all_before_last(':').trim(':') == '' {
} else if _ := addr.index('::') {
// ipv6 host only ::1
if addr.all_before_last('::') == '' {
return addr, 0
} else {
// ip:port
// addr:port
address := addr.all_before_last(':')
port := addr.all_after_last(':').int()
p := validate_port(port)!
return address, p
}
} else if _ := addr.index(':') {
// addr:port
address := addr.all_before_last(':')
p := validate_port(addr.all_after_last(':').int())!
return address, p
} else {
// addr only
address := addr.all_before_last(':')
return address, 0
return addr, 0
}
}

0 comments on commit 88feb47

Please sign in to comment.