Quantcast
Viewing all articles
Browse latest Browse all 2

Answer by Alex Netkachov for How can I unescape a url's host?

You can use url.QueryUnescape to decode entities %hh back to the characters:

package mainimport ("fmt""net/url""strings")func fixHost(link string) string {  if strings.HasPrefix(link, "http://") {    p := strings.Index(link[7:], "/")    if -1 != p {      host, _ := url.QueryUnescape(link[7:7+p])      return "http://"+ host + link[7+p:]    }  }  return link}func main() {  fmt.Println(fixHost("http://shitenonions%2elibsyn%2ecom/rss"))}

Viewing all articles
Browse latest Browse all 2

Trending Articles