validateDiffURL checks that the value is a syntactically valid HTTP(S) URL. The check is intentionally forge-agnostic because the diff URL on a chat may point to a pull request, merge request, branch page, etc.
(raw string)
| 628 | // URL. The check is intentionally forge-agnostic because the diff URL on |
| 629 | // a chat may point to a pull request, merge request, branch page, etc. |
| 630 | func validateDiffURL(raw string) error { |
| 631 | u, err := url.Parse(raw) |
| 632 | if err != nil { |
| 633 | return xerrors.Errorf("diff_url is not a valid URL: %w", err) |
| 634 | } |
| 635 | if u.Scheme != "http" && u.Scheme != "https" { |
| 636 | return xerrors.Errorf("diff_url must use http or https scheme, got %q", u.Scheme) |
| 637 | } |
| 638 | if u.Host == "" { |
| 639 | return xerrors.New("diff_url must include a host") |
| 640 | } |
| 641 | return nil |
| 642 | } |
| 643 | |
| 644 | func searchTerms(query string, defaultKey func(term string, values url.Values) error) (url.Values, []codersdk.ValidationError) { |
| 645 | searchValues := make(url.Values) |