diff options
author | Michael Muré <batolettre@gmail.com> | 2018-09-25 17:55:20 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-09-25 17:55:20 +0200 |
commit | 5d7c3a76af85a857a6bb0bff5bac5282c0a9908f (patch) | |
tree | dc0d051f09128a96eefba7a6d8cac458bb4e5379 /util | |
parent | a72ea453a919b8f456cc46fbb7a1156d9f649442 (diff) | |
download | git-bug-5d7c3a76af85a857a6bb0bff5bac5282c0a9908f.tar.gz |
bug: add the optional field AvatarUrl to Person
Diffstat (limited to 'util')
-rw-r--r-- | util/text/validate.go | 11 |
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 +} |