first commit

This commit is contained in:
ferdzo
2025-08-06 21:12:23 +02:00
commit b5115db152
18 changed files with 647 additions and 0 deletions

25
utils/utils.go Normal file
View File

@@ -0,0 +1,25 @@
package utils
import (
"net/url"
"regexp"
"strings"
)
func IsValidUrl(s string) bool {
if !strings.HasPrefix(s, "http://") && !strings.HasPrefix(s, "https://") {
return false
}
domainRegex := `^([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$`
parsedUrl, err := url.ParseRequestURI(s)
if err != nil {
return false
}
matched, err := regexp.MatchString(domainRegex, parsedUrl.Host)
if err != nil || !matched {
return false
}
return true
}