forked from sloum/bombadillo
Updated url regex to allow for any scheme
This commit is contained in:
parent
5e68d81a63
commit
7896858fac
3
url.go
3
url.go
|
@ -37,7 +37,7 @@ type Url struct {
|
|||
// an error (or nil).
|
||||
func MakeUrl(u string) (Url, error) {
|
||||
var out Url
|
||||
re := regexp.MustCompile(`^((?P<scheme>gopher|telnet|http|https|gemini):\/\/)?(?P<host>[\w\-\.\d]+)(?::(?P<port>\d+)?)?(?:/(?P<type>[01345679gIhisp])?)?(?P<resource>.*)?$`)
|
||||
re := regexp.MustCompile(`^((?P<scheme>[a-zA-Z]+):\/\/)?(?P<host>[\w\-\.\d]+)(?::(?P<port>\d+)?)?(?:/(?P<type>[01345679gIhisp])?)?(?P<resource>.*)?$`)
|
||||
match := re.FindStringSubmatch(u)
|
||||
|
||||
if valid := re.MatchString(u); !valid {
|
||||
|
@ -58,6 +58,7 @@ func MakeUrl(u string) (Url, error) {
|
|||
out.Resource = match[i]
|
||||
}
|
||||
}
|
||||
out.Scheme = strings.ToLower(out.Scheme)
|
||||
|
||||
if out.Scheme == "" {
|
||||
out.Scheme = "gopher"
|
||||
|
|
Loading…
Reference in New Issue