MCPcopy Create free account
hub / github.com/astercloud/aster / sanitizeAgentIDForPath

Function sanitizeAgentIDForPath

pkg/store/json.go:23–37  ·  view source on GitHub ↗

sanitizeAgentIDForPath 将 AgentID 转换为适合作为文件系统目录名的字符串。 主要目的是避免在 Windows 等平台上出现 ":"、"\" 等保留字符导致的路径错误。

(agentID string)

Source from the content-addressed store, hash-verified

21// sanitizeAgentIDForPath 将 AgentID 转换为适合作为文件系统目录名的字符串。
22// 主要目的是避免在 Windows 等平台上出现 ":"、"\" 等保留字符导致的路径错误。
23func sanitizeAgentIDForPath(agentID string) string {
24 // 替换常见的路径/保留字符为下划线
25 replacer := strings.NewReplacer(
26 ":", "_",
27 "/", "_",
28 "\\", "_",
29 "*", "_",
30 "?", "_",
31 "\"", "_",
32 "<", "_",
33 ">", "_",
34 "|", "_",
35 )
36 return replacer.Replace(agentID)
37}
38
39// NewJSONStore 创建JSON存储
40func NewJSONStore(baseDir string) (*JSONStore, error) {

Callers 1

agentDirMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected