github.com/creativeprojects/go-selfupdate@v1.2.0/token.go (about) 1 package selfupdate 2 3 import ( 4 "net/url" 5 "strings" 6 ) 7 8 // canUseTokenForDomain returns true if other URL is in the same domain as origin URL 9 func canUseTokenForDomain(origin, other string) (bool, error) { 10 originURL, err := url.Parse(origin) 11 if err != nil { 12 return false, err 13 } 14 otherURL, err := url.Parse(other) 15 if err != nil { 16 return false, err 17 } 18 return originURL.Hostname() != "" && strings.HasSuffix(otherURL.Hostname(), originURL.Hostname()), nil 19 }