MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / prettyPurl

Function prettyPurl

app/cli/cmd/workflow_workflow_run_describe.go:406–421  ·  view source on GitHub ↗

prettyPurl shortens "pkg:type/[namespace/]name@version[?qualifiers][#sub]" to "name@version" with percent-decoding applied — PURL requires `+` in version strings to be encoded as %2B, which is unreadable in CLI output.

(purl string)

Source from the content-addressed store, hash-verified

404// to "name@version" with percent-decoding applied — PURL requires `+` in
405// version strings to be encoded as %2B, which is unreadable in CLI output.
406func prettyPurl(purl string) string {
407 if purl == "" {
408 return ""
409 }
410 s := strings.TrimPrefix(purl, "pkg:")
411 if i := strings.IndexAny(s, "?#"); i >= 0 {
412 s = s[:i]
413 }
414 if i := strings.LastIndex(s, "/"); i >= 0 {
415 s = s[i+1:]
416 }
417 if decoded, err := url.PathUnescape(s); err == nil {
418 s = decoded
419 }
420 return s
421}
422
423func encodeAttestationOutput(run *action.WorkflowRunItemFull, writer io.Writer) error {
424 // Try to encode as a table or json

Callers 1

violationSummaryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected