package validate

import (
	"net"
	"net/url"
	"regexp"
	"strings"
)

func URL(text string) bool {
	url, err := url.Parse(text)
	if err != nil {
		return false
	}

	address := net.ParseIP(url.Host)

	if address == nil {
		regex := regexp.MustCompile(`\b\w+:\d+\b`)
		return strings.Contains(url.Host, ".") || regex.MatchString(url.Host)
	}

	if IsStringEmpty(url.Scheme) || IsStringEmpty(url.Host) {
		return false
	}

	return true
}
