diff --git a/central/central.go b/central/central.go index f3f3e249..20bfed9c 100644 --- a/central/central.go +++ b/central/central.go @@ -15,11 +15,11 @@ import ( "text/template" "time" + "github.com/k1LoW/octocov/badge" "github.com/k1LoW/octocov/datastore" "github.com/k1LoW/octocov/datastore/local" "github.com/k1LoW/octocov/gh" "github.com/k1LoW/octocov/internal" - "github.com/k1LoW/octocov/badge" "github.com/k1LoW/octocov/report" ) @@ -266,8 +266,8 @@ func (c *Central) renderIndex(wr io.Writer) error { d := map[string]any{ "Host": host, "Reports": c.reports, - "BadgesLinkRel": badgesLinkRel, - "BadgesURLRel": badgesURLRel, + "BadgesLinkRel": filepath.ToSlash(badgesLinkRel), + "BadgesURLRel": filepath.ToSlash(badgesURLRel), "RootURL": rootURL, "IsPrivate": isPrivate, "Query": query, diff --git a/config/build.go b/config/build.go index fa864990..dba48177 100644 --- a/config/build.go +++ b/config/build.go @@ -4,7 +4,6 @@ import ( "fmt" "os" "path/filepath" - "strings" "github.com/k1LoW/octocov/internal" ) @@ -45,7 +44,7 @@ func (c *Config) Build() { if c.Central.Root == "" { c.Central.Root = "." } - if !strings.HasPrefix(c.Central.Root, "/") { + if !filepath.IsAbs(c.Central.Root) { c.Central.Root = filepath.Clean(filepath.Join(c.Root(), c.Central.Root)) } if len(c.Central.Reports.Datastores) == 0 { diff --git a/config/config.go b/config/config.go index 94b41233..8cf57926 100644 --- a/config/config.go +++ b/config/config.go @@ -165,7 +165,7 @@ func (c *Config) Load(path string) error { if path == "" { return nil } - if strings.HasPrefix(path, "/") { + if filepath.IsAbs(path) { c.path = path } else { c.path = filepath.Join(c.wd, path) diff --git a/coverage/coverage.go b/coverage/coverage.go index dd65cab5..6c555657 100644 --- a/coverage/coverage.go +++ b/coverage/coverage.go @@ -94,7 +94,7 @@ func (fc FileCoverages) FuzzyFindByFile(file string) (*FileCoverage, error) { // continue } // When coverages are recorded in the package path. ( ex. org/repo/package/path/to/Target.kt - if !strings.HasPrefix(c.File, "/") && strings.HasSuffix(file, c.File) { + if !filepath.IsAbs(c.File) && strings.HasSuffix(file, c.File) { if match == nil || len(match.File) > len(c.File) { match = c } @@ -130,7 +130,7 @@ func (fc FileCoverages) PathPrefix() (string, error) { //nostyle:recvtype p = p[:i] } s := strings.Join(p, "/") - if s == "" && strings.HasPrefix(fc[0].File, "/") { + if s == "" && filepath.IsAbs(fc[0].File) { s = "/" } if s == "." { @@ -174,7 +174,7 @@ func (dc DiffFileCoverages) FuzzyFindByFile(file string) (*DiffFileCoverage, err continue } // When coverages are recorded in the package path. ( ex. org/repo/package/path/to/Target.kt - if !strings.HasPrefix(c.File, "/") && strings.HasSuffix(file, c.File) { + if !filepath.IsAbs(c.File) && strings.HasSuffix(file, c.File) { if match == nil || len(match.File) > len(c.File) { match = c } diff --git a/datastore/datastore.go b/datastore/datastore.go index d7e4012a..944f3bd9 100644 --- a/datastore/datastore.go +++ b/datastore/datastore.go @@ -222,7 +222,7 @@ func parse(u, root string) (Type, []string, error) { return Mackerel, []string{service}, nil default: p := strings.TrimSuffix(strings.TrimPrefix(strings.TrimPrefix(u, "file://"), "local://"), "/") - if strings.HasPrefix(p, "/") { + if filepath.IsAbs(p) { root = p } else { root = filepath.Join(root, p)