Support subdir in baseurl.

Mainly this was a change to helpers.MakePermalink, but to get the local server to run correctly,
we needed to redirect the path of the request from /foo to /.  In addition, I added tests for the
server's code for fixing up the base url with different config file & CLI options.
This commit is contained in:
Nate Finch
2014-08-22 07:59:59 -04:00
committed by spf13
parent 4b979b17cc
commit a31edb3388
5 changed files with 139 additions and 21 deletions

View File

@@ -33,7 +33,7 @@ func TestPermalink(t *testing.T) {
{"x/y/z/boofar.md", "x/y/z", "", "", "/z/y/q/", false, "/z/y/q/", "/z/y/q/"},
}
for _, test := range tests {
for i, test := range tests {
viper.Set("uglyurls", test.uglyurls)
p := &Page{
Node: Node{
@@ -56,22 +56,22 @@ func TestPermalink(t *testing.T) {
u, err := p.Permalink()
if err != nil {
t.Errorf("Unable to process permalink: %s", err)
t.Errorf("Test %d: Unable to process permalink: %s", i, err)
}
expected := test.expectedAbs
if u != expected {
t.Errorf("Expected abs url: %s, got: %s", expected, u)
t.Errorf("Test %d: Expected abs url: %s, got: %s", i, expected, u)
}
u, err = p.RelPermalink()
if err != nil {
t.Errorf("Unable to process permalink: %s", err)
t.Errorf("Test %d: Unable to process permalink: %s", i, err)
}
expected = test.expectedRel
if u != expected {
t.Errorf("Expected abs url: %s, got: %s", expected, u)
t.Errorf("Test %d: Expected abs url: %s, got: %s", i, expected, u)
}
}
}