aboutsummaryrefslogtreecommitdiffstats
path: root/util/text/validate.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-09-25 17:55:20 +0200
committerMichael Muré <batolettre@gmail.com>2018-09-25 17:55:20 +0200
commit5d7c3a76af85a857a6bb0bff5bac5282c0a9908f (patch)
treedc0d051f09128a96eefba7a6d8cac458bb4e5379 /util/text/validate.go
parenta72ea453a919b8f456cc46fbb7a1156d9f649442 (diff)
downloadgit-bug-5d7c3a76af85a857a6bb0bff5bac5282c0a9908f.tar.gz
bug: add the optional field AvatarUrl to Person
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
+}