diff options
author | Helder Pereira <helfper@gmail.com> | 2020-06-14 10:14:56 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2020-06-14 14:08:41 +0200 |
commit | 145b3fcce35fbac25c7033c91c1b7ae6d1179da8 (patch) | |
tree | cdcf5e36e05c5fe3ba36039a830eff9bf10e60df /hugolib/alias_test.go | |
parent | 01e249e97ce9a3bc145f4372a032b9da3e123a62 (diff) |
Fix aliases with relativeURLs
Diffstat (limited to 'hugolib/alias_test.go')
-rw-r--r-- | hugolib/alias_test.go | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/hugolib/alias_test.go b/hugolib/alias_test.go index b0491c13e..17c663496 100644 --- a/hugolib/alias_test.go +++ b/hugolib/alias_test.go @@ -45,18 +45,29 @@ func TestAlias(t *testing.T) { t.Parallel() c := qt.New(t) - b := newTestSitesBuilder(t) - b.WithSimpleConfigFile().WithContent("blog/page.md", pageWithAlias) - b.CreateSites().Build(BuildCfg{}) - - c.Assert(len(b.H.Sites), qt.Equals, 1) - c.Assert(len(b.H.Sites[0].RegularPages()), qt.Equals, 1) + tests := []struct { + urlPrefix string + settings map[string]interface{} + }{ + {"http://example.com", map[string]interface{}{"baseURL": "http://example.com"}}, + {"http://example.com", map[string]interface{}{"baseURL": "http://example.com", "canonifyURLs": true}}, + {"../..", map[string]interface{}{"relativeURLs": true}}, + } - // the real page - b.AssertFileContent("public/blog/page/index.html", "For some moments the old man") - // the alias redirectors - b.AssertFileContent("public/foo/bar/index.html", "<meta http-equiv=\"refresh\" content=\"0; ") - b.AssertFileContent("public/blog/rel/index.html", "<meta http-equiv=\"refresh\" content=\"0; ") + for _, test := range tests { + b := newTestSitesBuilder(t) + b.WithSimpleConfigFileAndSettings(test.settings).WithContent("blog/page.md", pageWithAlias) + b.CreateSites().Build(BuildCfg{}) + + c.Assert(len(b.H.Sites), qt.Equals, 1) + c.Assert(len(b.H.Sites[0].RegularPages()), qt.Equals, 1) + + // the real page + b.AssertFileContent("public/blog/page/index.html", "For some moments the old man") + // the alias redirectors + b.AssertFileContent("public/foo/bar/index.html", "<meta http-equiv=\"refresh\" content=\"0; url="+test.urlPrefix+"/blog/page/\" />") + b.AssertFileContent("public/blog/rel/index.html", "<meta http-equiv=\"refresh\" content=\"0; url="+test.urlPrefix+"/blog/page/\" />") + } } func TestAliasMultipleOutputFormats(t *testing.T) { |