From be10d10c43525d95e1c5c577ac787f7dc508b55f Mon Sep 17 00:00:00 2001 From: Justin Kehoe Date: Sun, 12 Apr 2026 17:28:16 -0500 Subject: [PATCH] fix: normalize file paths to forward slashes for cross-platform compatibility Fixes #8 --- internal/indexer/scanner.go | 2 +- internal/resolver/python/python.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/indexer/scanner.go b/internal/indexer/scanner.go index fde489b..57e4eb1 100644 --- a/internal/indexer/scanner.go +++ b/internal/indexer/scanner.go @@ -190,7 +190,7 @@ func (s *Scanner) scanFile(absPath, lang string) (ScannedFile, error) { } return ScannedFile{ - Path: relPath, + Path: filepath.ToSlash(relPath), AbsPath: absPath, ContentHash: fmt.Sprintf("%x", hash), Language: lang, diff --git a/internal/resolver/python/python.go b/internal/resolver/python/python.go index 699f09a..866124f 100644 --- a/internal/resolver/python/python.go +++ b/internal/resolver/python/python.go @@ -69,7 +69,7 @@ func (r *Resolver) DetectPackageRoots() ([]PackageRoot, error) { if fileExists(filepath.Join(absSubdir, "pyproject.toml")) || fileExists(filepath.Join(absSubdir, "setup.py")) { roots = appendIfNewPath(roots, PackageRoot{Path: subdir, DetectionMethod: "monorepo_subdir"}) if dirExists(filepath.Join(absSubdir, "src")) { - roots = appendIfNewPath(roots, PackageRoot{Path: filepath.Join(subdir, "src"), DetectionMethod: "src_layout"}) + roots = appendIfNewPath(roots, PackageRoot{Path: filepath.ToSlash(filepath.Join(subdir, "src")), DetectionMethod: "src_layout"}) } } } @@ -177,7 +177,7 @@ func (r *Resolver) resolveRelative(srcFile string, fact model.ImportFact) model. } } // Check for __init__.py in the base dir itself. - initPath := filepath.Join(baseDir, "__init__.py") + initPath := filepath.ToSlash(filepath.Join(baseDir, "__init__.py")) if fileExists(filepath.Join(r.repoRoot, initPath)) { return model.ResolveResult{ ResolvedPath: initPath, @@ -273,13 +273,13 @@ func resolveModulePath(repoRoot, base, modulePath string) string { relPath := strings.ReplaceAll(modulePath, ".", string(filepath.Separator)) // Try as .py file. - pyFile := filepath.Join(base, relPath+".py") + pyFile := filepath.ToSlash(filepath.Join(base, relPath+".py")) if fileExists(filepath.Join(repoRoot, pyFile)) { return pyFile } // Try as package __init__.py. - initFile := filepath.Join(base, relPath, "__init__.py") + initFile := filepath.ToSlash(filepath.Join(base, relPath, "__init__.py")) if fileExists(filepath.Join(repoRoot, initFile)) { return initFile }