diff --git a/hugolib/integrationtest_builder.go b/hugolib/integrationtest_builder.go
index d83a5d640..c840a5eec 100644
--- a/hugolib/integrationtest_builder.go
+++ b/hugolib/integrationtest_builder.go
@@ -429,6 +429,16 @@ func (s *IntegrationTestBuilder) negate(match string) (string, bool) {
return match, negate
}
+// AssertFileContentStartsWith asserts that the content of the given file starts with s.
+func (s *IntegrationTestBuilder) AssertFileContentStartsWith(filename, prefix string) {
+ s.Helper()
+ content := strings.TrimSpace(s.FileContent(filename))
+ cm := qt.Commentf("File: %s Expect:\n%s Got:\n%s\nWith Space Visuals:\n%s", filename, prefix, content, util.VisualizeSpaces([]byte(content)))
+ var negate bool
+ prefix, negate = s.negate(prefix)
+ s.Assert(strings.HasPrefix(content, prefix), qt.Equals, !negate, cm)
+}
+
func (s *IntegrationTestBuilder) AssertFileContent(filename string, matches ...string) {
s.Helper()
content := strings.TrimSpace(s.FileContent(filename))
diff --git a/hugolib/sitemap_test.go b/hugolib/sitemap_test.go
index 5f536ecf2..c2062caa7 100644
--- a/hugolib/sitemap_test.go
+++ b/hugolib/sitemap_test.go
@@ -42,7 +42,10 @@ Doc2
b := Test(t, files)
- b.AssertFileContent("public/sitemap.xml", " https://example.com/sect/doc1/", "doc2")
+ b.AssertFileContentStartsWith("public/sitemap.xml", `https://example.com/sect/doc1/", "doc2",
+ )
}
func TestSitemapMultilingual(t *testing.T) {
diff --git a/tpl/tplimpl/embedded/templates/sitemap.xml b/tpl/tplimpl/embedded/templates/sitemap.xml
index 2e873abe7..a1bc86310 100644
--- a/tpl/tplimpl/embedded/templates/sitemap.xml
+++ b/tpl/tplimpl/embedded/templates/sitemap.xml
@@ -1,4 +1,4 @@
-{{/* gotmplfmt-ignore-all */}}
+{{/* gotmplfmt-ignore-all */ -}}
{{ printf "" | safeHTML }}