I dont know what is the source of string it can be url encoded how do I test it whether it is a normal string or url encoded string this using this particular code
func decode(str1 string) { //str1 := "elementINPUT61599119%5B%5D" resl, err := url.QueryUnescape(str1) log.Println(err) return resl } func ifUrlEncoded(string string) bool{ if //function{ return true } return false } func main(){ if ifUrlEncoded(str){ fmt.Println(decode(str)) } else{ fmt.Println(str) } }
"%20", maybe it's an encoded space character, or maybe it's literally supposed to be `'%', '2', '0'``Query()on the request'sURLfield which deals with that. If your code is not related to handling requests, you have to guess. For instance, you could look for%in the URL, and if one found, decode it and then validate whether you got back a valid URL; if the result is not valid, the source URL was probably not encoded. Still, it will only be a guess.