Browse Source

Improved URL validation

master
Christopher Ramey 6 years ago
committed by cdramey
parent
commit
fefd6dbdce
  1. 8
      qurl/qurl.go

8
qurl/qurl.go

@ -29,6 +29,14 @@ func (q *QURL) CheckValid() error {
return err 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() { if !u.IsAbs() {
return fmt.Errorf("Relative URLs are not allowed") return fmt.Errorf("Relative URLs are not allowed")
} }

Loading…
Cancel
Save