github.com/snowflakedb/gosnowflake@v1.9.0/url_util.go (about) 1 package gosnowflake 2 3 import ( 4 "net/url" 5 "regexp" 6 ) 7 8 var ( 9 matcher, _ = regexp.Compile(`^http(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z@:])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\&\(\)\/\\\+&%\$#_=@]*)?$`) 10 ) 11 12 func isValidURL(targetURL string) bool { 13 if !matcher.MatchString(targetURL) { 14 logger.Infof(" The provided URL is not a valid URL - " + targetURL) 15 return false 16 } 17 return true 18 } 19 20 func urlEncode(targetString string) string { 21 // We use QueryEscape instead of PathEscape here 22 // for consistency across Drivers. For example: 23 // QueryEscape escapes space as "+" whereas PE 24 // it as %20F. PE also does not escape @ or & 25 // either but QE does. 26 // The behavior of QE in Golang is more in sync 27 // with URL encoders in Python and Java hence the choice 28 return url.QueryEscape(targetString) 29 }