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)
| 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. |
| 406 | func 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 | |
| 423 | func encodeAttestationOutput(run *action.WorkflowRunItemFull, writer io.Writer) error { |
| 424 | // Try to encode as a table or json |