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

Method resolvePath

pkg/memory/memory.go:237–247  ·  view source on GitHub ↗

resolvePath 将相对名称解析为 memoryPath 下的完整路径

(name string)

Source from the content-addressed store, hash-verified

235
236// resolvePath 将相对名称解析为 memoryPath 下的完整路径
237func (m *Manager) resolvePath(name string) string {
238 name = strings.TrimSpace(name)
239 name = strings.TrimLeft(name, "/")
240 joined := filepath.ToSlash(filepath.Join(m.memoryPath, name))
241
242 // 确保不会逃出 memoryPath 根目录
243 if !strings.HasPrefix(joined, m.memoryPath) {
244 return m.memoryPath + name
245 }
246 return joined
247}

Callers 4

ReadFileMethod · 0.95
AppendNoteMethod · 0.95
OverwriteWithNoteMethod · 0.95
SearchMethod · 0.95

Calls 1

JoinMethod · 0.45

Tested by

no test coverage detected