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

Function validateResourceParameter

coderd/oauth2provider/tokens.go:496–515  ·  view source on GitHub ↗

validateResourceParameter validates that a resource parameter conforms to RFC 8707: must be an absolute URI without fragment component.

(resource string)

Source from the content-addressed store, hash-verified

494// validateResourceParameter validates that a resource parameter conforms to RFC 8707:
495// must be an absolute URI without fragment component.
496func validateResourceParameter(resource string) error {
497 if resource == "" {
498 return nil // Resource parameter is optional
499 }
500
501 u, err := url.Parse(resource)
502 if err != nil {
503 return xerrors.Errorf("invalid URI syntax: %w", err)
504 }
505
506 if u.Scheme == "" {
507 return xerrors.New("must be an absolute URI with scheme")
508 }
509
510 if u.Fragment != "" {
511 return xerrors.New("must not contain fragment component")
512 }
513
514 return nil
515}

Callers 2

extractAuthorizeParamsFunction · 0.85
extractTokenRequestFunction · 0.85

Calls 3

ParseMethod · 0.65
NewMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected