Skip to content

Commit

Permalink
Ensure that BaseUrl used in hugo server ends with /
Browse files Browse the repository at this point in the history
Fixes #793, #799
  • Loading branch information
anthonyfok committed Jan 16, 2015
1 parent 9150a98 commit 1cbdd3e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions commands/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ func serve(port int) {
}
}

// fixUrl massages the BaseUrl into a form needed for serving
// all pages correctly.
func fixUrl(s string) (string, error) {
useLocalhost := false
if s == "" {
Expand All @@ -144,6 +146,9 @@ func fixUrl(s string) (string, error) {
if !strings.HasPrefix(s, "http://") && !strings.HasPrefix(s, "https://") {
s = "http://" + s
}
if !strings.HasSuffix(s, "/") {
s = s + "/"
}
u, err := url.Parse(s)
if err != nil {
return "", err
Expand Down

0 comments on commit 1cbdd3e

Please sign in to comment.