Allow URL with extension in frontmatter

Fixes #1923
This commit is contained in:
Bjørn Erik Pedersen
2016-03-05 20:18:17 +01:00
parent 3c100cc32c
commit 27f8d8f963
2 changed files with 42 additions and 12 deletions

View File

@@ -419,14 +419,15 @@ THE END.`, refShortcode))},
}
// Issue #939
func Test404ShouldAlwaysHaveUglyURLs(t *testing.T) {
// Issue #1923
func TestShouldAlwaysHaveUglyURLs(t *testing.T) {
hugofs.DestinationFS = new(afero.MemMapFs)
for _, uglyURLs := range []bool{true, false} {
doTest404ShouldAlwaysHaveUglyURLs(t, uglyURLs)
doTestShouldAlwaysHaveUglyURLs(t, uglyURLs)
}
}
func doTest404ShouldAlwaysHaveUglyURLs(t *testing.T, uglyURLs bool) {
func doTestShouldAlwaysHaveUglyURLs(t *testing.T, uglyURLs bool) {
viper.Reset()
defer viper.Reset()
@@ -436,11 +437,15 @@ func doTest404ShouldAlwaysHaveUglyURLs(t *testing.T, uglyURLs bool) {
viper.Set("DisableSitemap", false)
viper.Set("DisableRSS", false)
viper.Set("RSSUri", "index.xml")
viper.Set("blackfriday",
map[string]interface{}{
"plainIDAnchors": true})
viper.Set("UglyURLs", uglyURLs)
sources := []source.ByteSource{
{filepath.FromSlash("sect/doc1.html"), []byte("---\nmarkup: markdown\n---\n# title\nsome *content*")},
{filepath.FromSlash("sect/doc1.md"), []byte("---\nmarkup: markdown\n---\n# title\nsome *content*")},
{filepath.FromSlash("sect/doc2.md"), []byte("---\nurl: /ugly.html\nmarkup: markdown\n---\n# title\ndoc2 *content*")},
}
s := &Site{
@@ -475,10 +480,12 @@ func doTest404ShouldAlwaysHaveUglyURLs(t *testing.T, uglyURLs bool) {
expected string
}{
{filepath.FromSlash("index.html"), "Home Sweet Home. IsHome=true"},
{filepath.FromSlash(expectedPagePath), "\n\n<h1 id=\"title:5d74edbb89ef198cd37882b687940cda\">title</h1>\n\n<p>some <em>content</em></p>\n IsHome=false"},
{filepath.FromSlash(expectedPagePath), "\n\n<h1 id=\"title\">title</h1>\n\n<p>some <em>content</em></p>\n IsHome=false"},
{filepath.FromSlash("404.html"), "Page Not Found. IsHome=false"},
{filepath.FromSlash("index.xml"), "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n<root>RSS</root>"},
{filepath.FromSlash("sitemap.xml"), "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n<root>SITEMAP</root>"},
// Issue #1923
{filepath.FromSlash("ugly.html"), "\n\n<h1 id=\"title\">title</h1>\n\n<p>doc2 <em>content</em></p>\n IsHome=false"},
}
for _, p := range s.Pages {