mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
20 lines
360 B
Go
20 lines
360 B
Go
|
package urlutil
|
||
|
|
||
|
import "strings"
|
||
|
|
||
|
var validUrlPrefixes = []string{
|
||
|
"http://",
|
||
|
"https://",
|
||
|
}
|
||
|
|
||
|
// IsURL returns true if the provided str is a valid URL by doing
|
||
|
// a simple change for the transport of the url.
|
||
|
func IsURL(str string) bool {
|
||
|
for _, prefix := range validUrlPrefixes {
|
||
|
if strings.HasPrefix(str, prefix) {
|
||
|
return true
|
||
|
}
|
||
|
}
|
||
|
return false
|
||
|
}
|