internetarchive / Zeno

State-of-the-art web crawler 🔱
GNU Affero General Public License v3.0
81 stars 10 forks source link

create url_string_test.go #97

Open willmhowes opened 3 months ago

willmhowes commented 3 months ago

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 commented 3 months ago

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

CorentinB commented 3 months ago

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