Closed xeoncross closed 7 years ago
Hello David,
Typically this is passed to http.Get
or http.NewRequest
, and the url.URL
is a pointer, so the URL you passed in is modified and normalized in-place, no need to return it. If you need the url.URL
, you can just use the one you passed in. (There's a minor caveat to this regarding the urlesc
package which doesn't escape in-place)
Martin
So since the urlesc.Escape() method simply returns a string, then if I don't pass the result of NormalizeURL()
back to url.Parse() then I'll lose some of the proper escaping done by urlesc
and possibly end up with a less-than-normalized URL.
Recent versions of Go properly escape, so that call to urlesc
should not be necessary now. So your url.URL would be ok (see #14 that I haven't had time to address yet).
Why does the NormalizeURL() function take a url.URL but return a string? There are already functions for dealing with string URL's.