Merges 2.0.0 into master for final release #106
3
url.go
3
url.go
|
@ -37,7 +37,7 @@ type Url struct {
|
||||||
// an error (or nil).
|
// an error (or nil).
|
||||||
func MakeUrl(u string) (Url, error) {
|
func MakeUrl(u string) (Url, error) {
|
||||||
var out Url
|
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)
|
match := re.FindStringSubmatch(u)
|
||||||
|
|
||||||
if valid := re.MatchString(u); !valid {
|
if valid := re.MatchString(u); !valid {
|
||||||
|
@ -58,6 +58,7 @@ func MakeUrl(u string) (Url, error) {
|
||||||
out.Resource = match[i]
|
out.Resource = match[i]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
out.Scheme = strings.ToLower(out.Scheme)
|
||||||
|
|
||||||
if out.Scheme == "" {
|
if out.Scheme == "" {
|
||||||
out.Scheme = "gopher"
|
out.Scheme = "gopher"
|
||||||
|
|
Loading…
Reference in New Issue