π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
package network
import (
"net"
"net/url"
"strings"
)
func IsLoopbackOrigin(origin string) bool {
parsed, err := url.Parse(strings.TrimSpace(origin))
if err != nil || !strings.EqualFold(parsed.Scheme, "http") && !strings.EqualFold(parsed.Scheme, "https") {
return false
}
host := strings.ToLower(strings.TrimSuffix(parsed.Hostname(), "."))
ip := net.ParseIP(host)
return host == "localhost" || strings.HasSuffix(host, ".localhost") || ip != nil && ip.IsLoopback()
}