MCPcopy Index your code
hub / github.com/coder/coder / validateDiffURL

Function validateDiffURL

coderd/searchquery/search.go:630–642  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
630func 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
644func searchTerms(query string, defaultKey func(term string, values url.Values) error) (url.Values, []codersdk.ValidationError) {
645 searchValues := make(url.Values)

Callers 1

ChatsFunction · 0.85

Calls 3

ParseMethod · 0.65
NewMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected