externalRefBaseName extracts a short agent name from an external reference. - OCI: last path segment, tag/digest stripped "agentcatalog/review-pr" → "review-pr" "docker.io/myorg/myagent:v1" → "myagent" - URL: filename without extension "https://example.com/agent.yaml" → "agent"
(ref string)
| 315 | // - URL: filename without extension |
| 316 | // "https://example.com/agent.yaml" → "agent" |
| 317 | func externalRefBaseName(ref string) string { |
| 318 | if IsURLReference(ref) { |
| 319 | return fileNameWithoutExt(ref) |
| 320 | } |
| 321 | |
| 322 | // OCI reference: strip tag or digest, then take last path segment. |
| 323 | base := ref |
| 324 | if i := strings.LastIndex(base, "@"); i >= 0 { |
| 325 | base = base[:i] |
| 326 | } |
| 327 | if i := strings.LastIndex(base, ":"); i >= 0 { |
| 328 | // Only strip if the colon is after the last slash (i.e. it's a tag, not a port). |
| 329 | if j := strings.LastIndex(base, "/"); j < i { |
| 330 | base = base[:i] |
| 331 | } |
| 332 | } |
| 333 | if i := strings.LastIndex(base, "/"); i >= 0 { |
| 334 | base = base[i+1:] |
| 335 | } |
| 336 | return base |
| 337 | } |
no test coverage detected