From 9fe9d65b9066e48740f1b0dd767615306e32ee94 Mon Sep 17 00:00:00 2001
From: Donnie Adams <donnie@acorn.io>
Date: Wed, 20 Nov 2024 12:52:13 -0500
Subject: [PATCH] fix: trim ./ from local tool references

Signed-off-by: Donnie Adams <donnie@acorn.io>
---
 pkg/controller/handlers/toolreference/toolreference.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pkg/controller/handlers/toolreference/toolreference.go b/pkg/controller/handlers/toolreference/toolreference.go
index b9722c2f2..0f831ee25 100644
--- a/pkg/controller/handlers/toolreference/toolreference.go
+++ b/pkg/controller/handlers/toolreference/toolreference.go
@@ -57,8 +57,8 @@ func isValidTool(tool gptscript.Tool) bool {
 
 func (h *Handler) toolsToToolReferences(ctx context.Context, toolType types.ToolReferenceType, entries map[string]indexEntry) (result []client.Object) {
 	for name, entry := range entries {
-		if strings.HasPrefix(entry.Reference, ".") {
-			entry.Reference = h.registryURL + "/" + entry.Reference
+		if ref, ok := strings.CutPrefix(entry.Reference, "./"); ok {
+			entry.Reference = h.registryURL + "/" + ref
 		}
 
 		if entry.All {