Skip to content
Snippets Groups Projects
Commit 4f608888 authored by Francé Wilke's avatar Francé Wilke
Browse files

Merge branch 'adhoc-add-isurlstrict' into 'main'

Adds IsUrlStrict() to string_utils

See merge request uafrica/go-utils!18
parents fd2c31c5 cb21566a
No related branches found
No related tags found
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