Skip to content

Commit

Permalink
fix url for root path
Browse files Browse the repository at this point in the history
  • Loading branch information
dannyvankooten committed Nov 24, 2023
1 parent 9c2f444 commit 78e3709
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion gozer.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ func parseFilename(path string, rootDir string) (string, time.Time) {
}
}

path += "/"
if path != "" {
path += "/"
}

return path, time.Time{}
}

Expand Down
4 changes: 2 additions & 2 deletions gozer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestExampleSite(t *testing.T) {
},
{"favicon.ico", nil},
{"feed.xml", nil},
{"sitemap.xml", [][]byte{[]byte("<url><loc>http://localhost:8080//</loc>")}},
{"sitemap.xml", [][]byte{[]byte("<url><loc>http://localhost:8080/</loc>")}},
{"sitemap.xsl", nil},
}

Expand Down Expand Up @@ -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)},
Expand Down

0 comments on commit 78e3709

Please sign in to comment.