Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Sep 26, 2024
1 parent 4248fc5 commit 5248a2b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion vlib/net/util.v
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@ pub fn validate_port(port int) !u16 {
// split_address splits an address into its host name and its port
pub fn split_address(addr string) !(string, u16) {
port := addr.all_after_last(':').int()
address := addr.all_before_last(':')
mut address := addr.all_before_last(':')

// TODO(emily): Maybe do some more checking here
// to validate ipv6 address sanity?

// RFC4038 - allow [::1]:port
if address[0] == `[` && address[address.len - 1] == `]` {
address = address[1..address.len - 1]
}

p := validate_port(port)!
return address, p
}

0 comments on commit 5248a2b

Please sign in to comment.