Zeno icon indicating copy to clipboard operation
Zeno copied to clipboard

create url_string_test.go

Open willmhowes opened this issue 1 year ago • 2 comments

Pretty straightforward testing for URLToString function. But I'm still not quite sure what the following logic in URLToString does so I wasn't able to write a test for it (link):

if strings.Contains(tempHost, ":") && !(strings.HasPrefix(tempHost, "[") && strings.HasSuffix(tempHost, "]")) {
	tempHost = "[" + tempHost + "]"
}

@NGTmeaty Because you wrote it, could you add a test that verifies the above code is functioning as intended?

willmhowes avatar Jul 25 '24 16:07 willmhowes

I understand now that the code I referenced above is to handle IPv6 addresses, so I added a test for that functionality as well as a comment in the URLToString function to explain that line which I consider not immediately obvious. @NGTmeaty You can disregard my request above, but feel free to add any test cases I'm missing

willmhowes avatar Jul 25 '24 16:07 willmhowes

Yes indeed, it's for IPV6 IPs to have opening and closing brackets.

CorentinB avatar Jul 25 '24 21:07 CorentinB