aboutsummaryrefslogtreecommitdiffstats
path: root/util/text/validate.go
diff options
context:
space:
mode:
Diffstat (limited to 'util/text/validate.go')
-rw-r--r--util/text/validate.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/util/text/validate.go b/util/text/validate.go
index 68bdf48b..51e94fb4 100644
--- a/util/text/validate.go
+++ b/util/text/validate.go
@@ -1,6 +1,7 @@
package text
import (
+ "net/url"
"strings"
"unicode"
)
@@ -31,3 +32,13 @@ func Safe(s string) bool {
return true
}
+
+// ValidUrl will tell if the string contains what seems to be a valid URL
+func ValidUrl(s string) bool {
+ if strings.Contains(s, "\n") {
+ return false
+ }
+
+ _, err := url.ParseRequestURI(s)
+ return err == nil
+}