Improved URL validation

This commit is contained in:
Christopher Ramey 2018-11-17 17:17:22 +00:00 committed by cdramey
parent 9f13f8e09b
commit fefd6dbdce

View File

@ -29,6 +29,14 @@ func (q *QURL) CheckValid() error {
return err
}
if u.Scheme == "" {
return fmt.Errorf("URLs must begin with a scheme (e.g. https:)")
}
if u.Host == "" && u.RawQuery == "" && u.RawPath == "" && u.Fragment == "" {
return fmt.Errorf("URLs must contain a path, host, query or fragment element")
}
if !u.IsAbs() {
return fmt.Errorf("Relative URLs are not allowed")
}