MCPcopy Create free account
hub / github.com/53AI/53AIHub / normalizeSandboxRelativePath

Function normalizeSandboxRelativePath

api/service/tools/executor.go:779–797  ·  view source on GitHub ↗
(raw string)

Source from the content-addressed store, hash-verified

777}
778
779func normalizeSandboxRelativePath(raw string) (string, error) {
780 trimmed := strings.TrimSpace(raw)
781 if trimmed == "" {
782 return "", nil
783 }
784 normalized := strings.TrimLeft(trimmed, "/")
785 normalized = strings.TrimPrefix(normalized, "./")
786 if normalized == "" {
787 return ".", nil
788 }
789 normalized = filepath.ToSlash(filepath.Clean(normalized))
790 if normalized == "" || normalized == "." {
791 return ".", nil
792 }
793 if strings.HasPrefix(normalized, "../") || normalized == ".." {
794 return "", fmt.Errorf("path must be relative to the sandbox workspace: %s", raw)
795 }
796 return normalized, nil
797}
798
799func normalizeSandboxWorkspacePath(fileName string) (string, error) {
800 normalized, err := normalizeSandboxRelativePath(fileName)

Callers 10

executeRunShellFunction · 0.85
executeReadFileFunction · 0.85
executeEditFileFunction · 0.85
executeListFilesFunction · 0.85
resolveSandboxCWDFunction · 0.85

Calls 1

ErrorfMethod · 0.80

Tested by

no test coverage detected