Skip to content
Snippets Groups Projects
Commit cb21566a authored by Billy Griffiths's avatar Billy Griffiths
Browse files

Add IsUrlStrict() to string_utils

parent fd2c31c5
Branches
Tags
1 merge request!18Adds IsUrlStrict() to string_utils
......@@ -3,6 +3,7 @@ package string_utils
import (
"encoding/json"
"fmt"
"net/url"
"regexp"
"strconv"
"strings"
......@@ -280,3 +281,9 @@ func SplitString(str string, sep []rune) []string {
return splitStrings
}
// IsUrlStrict Returns whether a URL is valid in a strict way (Must have scheme and host)
func IsUrlStrict(str string) bool {
u, err := url.Parse(str)
return err == nil && u.Scheme != "" && u.Host != ""
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment