Skip to content

Commit

Permalink
fix: protect <autogenerated> path
Browse files Browse the repository at this point in the history
  • Loading branch information
Zxilly committed Jan 29, 2024
1 parent 3387a4c commit d350b1a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ func TestCommandLineArgumentsPagkageDetection(t *testing.T) {
}{
{"x_cgo_sys_thread_creater", ".", ClassSTD},
{"_cgo_sys_thread_star", ".", ClassSTD},
{"", ".", ClassGenerated},
{"", "<autogenerated>", ClassGenerated},
{"gopackage", "gopackage", ClassMain},
{"gopackage/subpackage", "gopackage/subpackage", ClassMain},
}
Expand Down
16 changes: 13 additions & 3 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,26 @@ package gore

import (
"path/filepath"
"strings"
)

func osAwarePathDir(s string) string {
return filepath.Dir(s)
if strings.Contains(s, "/") {
return filepath.Dir(s)
}
return s
}

func osAwarePathBase(s string) string {
return filepath.Base(s)
if strings.Contains(s, "/") {
return filepath.Base(s)
}
return s
}

func osAwarePathClean(s string) string {
return filepath.Clean(s)
if strings.Contains(s, "/") {
return filepath.Clean(s)
}
return s
}

0 comments on commit d350b1a

Please sign in to comment.