diff options
author | Bjørn Erik Pedersen <[email protected]> | 2018-01-11 17:46:43 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2018-01-12 10:39:09 +0100 |
commit | 57e10f174e51cc5e1cf5f37eed30a0f3b153dd64 (patch) | |
tree | 88d4057e3ec69368d196dcec00028940e05eba44 /hugolib/site_url_test.go | |
parent | db85e83403913cff4b8737b138932b28e5bf6160 (diff) | |
download | hugo-57e10f174e51cc5e1cf5f37eed30a0f3b153dd64.tar.gz hugo-57e10f174e51cc5e1cf5f37eed30a0f3b153dd64.zip |
Support uglyURLs per section
Fixes #4256
Diffstat (limited to 'hugolib/site_url_test.go')
-rw-r--r-- | hugolib/site_url_test.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/hugolib/site_url_test.go b/hugolib/site_url_test.go index 479967673..4839c5e63 100644 --- a/hugolib/site_url_test.go +++ b/hugolib/site_url_test.go @@ -87,3 +87,40 @@ func TestPageCount(t *testing.T) { } } } + +func TestUglyURLsPerSection(t *testing.T) { + t.Parallel() + + assert := require.New(t) + + const dt = `--- +title: Do not go gentle into that good night +--- + +Wild men who caught and sang the sun in flight, +And learn, too late, they grieved it on its way, +Do not go gentle into that good night. + +` + + cfg, fs := newTestCfg() + + cfg.Set("uglyURLs", map[string]bool{ + "sect2": true, + }) + + writeSource(t, fs, filepath.Join("content", "sect1", "p1.md"), dt) + writeSource(t, fs, filepath.Join("content", "sect2", "p2.md"), dt) + + s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg}, BuildCfg{SkipRender: true}) + + assert.Len(s.RegularPages, 2) + + notUgly := s.getPage(KindPage, "sect1/p1.md") + assert.NotNil(notUgly) + assert.Equal("/sect1/p1/", notUgly.RelPermalink()) + + ugly := s.getPage(KindPage, "sect2/p2.md") + assert.NotNil(ugly) + assert.Equal("/sect2/p2.html", ugly.RelPermalink()) +} |