diff --git a/gozer.go b/gozer.go index ebd3da9..17a5c55 100644 --- a/gozer.go +++ b/gozer.go @@ -67,7 +67,10 @@ func parseFilename(path string, rootDir string) (string, time.Time) { } } - path += "/" + if path != "" { + path += "/" + } + return path, time.Time{} } diff --git a/gozer_test.go b/gozer_test.go index 7160fa5..0457588 100644 --- a/gozer_test.go +++ b/gozer_test.go @@ -29,7 +29,7 @@ func TestExampleSite(t *testing.T) { }, {"favicon.ico", nil}, {"feed.xml", nil}, - {"sitemap.xml", [][]byte{[]byte("http://localhost:8080//")}}, + {"sitemap.xml", [][]byte{[]byte("http://localhost:8080/")}}, {"sitemap.xsl", nil}, } @@ -101,7 +101,7 @@ func TestFilepathToUrlpath(t *testing.T) { expectedUrlPath string expectedDatePublished time.Time }{ - {input: "content/index.md", expectedUrlPath: "/", expectedDatePublished: time.Time{}}, + {input: "content/index.md", expectedUrlPath: "", expectedDatePublished: time.Time{}}, {input: "content/about.md", expectedUrlPath: "about/", expectedDatePublished: time.Time{}}, {input: "content/projects/gozer.md", expectedUrlPath: "projects/gozer/", expectedDatePublished: time.Time{}}, {input: "content/2023-11-23-hello-world.md", expectedUrlPath: "hello-world/", expectedDatePublished: time.Date(2023, 11, 23, 0, 0, 0, 0, time.UTC)},