fix: correct abs to rel path conversion (#683)

This commit is contained in:
Shane-XB-Qian 2025-02-11 21:53:34 +08:00 committed by GitHub
commit f689c90084
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -425,8 +425,9 @@ func localFileToMarkdown(cwd string, res gitcha.SearchResult) *markdown {
}
func stripAbsolutePath(fullPath, cwd string) string {
path, _ := filepath.Rel(cwd, fullPath)
return path
fp, _ := filepath.EvalSymlinks(fullPath)
cp, _ := filepath.EvalSymlinks(cwd)
return strings.ReplaceAll(fp, cp+string(os.PathSeparator), "")
}
// Lightweight version of reflow's indent function.