From 7896858facaa28343b96d1ed7bea5b1f44c0a209 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Thu, 26 Sep 2019 18:30:44 -0700 Subject: [PATCH] Updated url regex to allow for any scheme --- url.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/url.go b/url.go index faedbbb..343cdbb 100644 --- a/url.go +++ b/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(`^((?Pgopher|telnet|http|https|gemini):\/\/)?(?P[\w\-\.\d]+)(?::(?P\d+)?)?(?:/(?P[01345679gIhisp])?)?(?P.*)?$`) + re := regexp.MustCompile(`^((?P[a-zA-Z]+):\/\/)?(?P[\w\-\.\d]+)(?::(?P\d+)?)?(?:/(?P[01345679gIhisp])?)?(?P.*)?$`) 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"