1 package utils 2 3 import ( 4 "bytes" 5 "net/url" 6 "strings" 7 ) 8 9 const filterIRIChars = "/#%[]=:;$&()+,!?*@'~" 10 11 func IRIEncode(in string) string { 12 var b bytes.Buffer 13 14 for _, r := range in { 15 if strings.IndexRune(filterIRIChars, r) >= 0 { 16 b.WriteRune(r) 17 } else { 18 b.WriteString(url.QueryEscape(string(r))) 19 } 20 } 21 22 return b.String() 23 } 24