Skip to content

Commit 012e658

Browse files
authored
fix: normalize file paths to forward slashes for cross-platform compatibility Fixes #8 (#13)
1 parent 5c3134b commit 012e658

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

internal/indexer/scanner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ func (s *Scanner) scanFile(absPath, lang string) (ScannedFile, error) {
190190
}
191191

192192
return ScannedFile{
193-
Path: relPath,
193+
Path: filepath.ToSlash(relPath),
194194
AbsPath: absPath,
195195
ContentHash: fmt.Sprintf("%x", hash),
196196
Language: lang,

internal/resolver/python/python.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (r *Resolver) DetectPackageRoots() ([]PackageRoot, error) {
6969
if fileExists(filepath.Join(absSubdir, "pyproject.toml")) || fileExists(filepath.Join(absSubdir, "setup.py")) {
7070
roots = appendIfNewPath(roots, PackageRoot{Path: subdir, DetectionMethod: "monorepo_subdir"})
7171
if dirExists(filepath.Join(absSubdir, "src")) {
72-
roots = appendIfNewPath(roots, PackageRoot{Path: filepath.Join(subdir, "src"), DetectionMethod: "src_layout"})
72+
roots = appendIfNewPath(roots, PackageRoot{Path: filepath.ToSlash(filepath.Join(subdir, "src")), DetectionMethod: "src_layout"})
7373
}
7474
}
7575
}
@@ -177,7 +177,7 @@ func (r *Resolver) resolveRelative(srcFile string, fact model.ImportFact) model.
177177
}
178178
}
179179
// Check for __init__.py in the base dir itself.
180-
initPath := filepath.Join(baseDir, "__init__.py")
180+
initPath := filepath.ToSlash(filepath.Join(baseDir, "__init__.py"))
181181
if fileExists(filepath.Join(r.repoRoot, initPath)) {
182182
return model.ResolveResult{
183183
ResolvedPath: initPath,
@@ -273,13 +273,13 @@ func resolveModulePath(repoRoot, base, modulePath string) string {
273273
relPath := strings.ReplaceAll(modulePath, ".", string(filepath.Separator))
274274

275275
// Try as .py file.
276-
pyFile := filepath.Join(base, relPath+".py")
276+
pyFile := filepath.ToSlash(filepath.Join(base, relPath+".py"))
277277
if fileExists(filepath.Join(repoRoot, pyFile)) {
278278
return pyFile
279279
}
280280

281281
// Try as package __init__.py.
282-
initFile := filepath.Join(base, relPath, "__init__.py")
282+
initFile := filepath.ToSlash(filepath.Join(base, relPath, "__init__.py"))
283283
if fileExists(filepath.Join(repoRoot, initFile)) {
284284
return initFile
285285
}

0 commit comments

Comments
 (0)