Redirect to main language from root

See #2312
See #2309
This commit is contained in:
Bjørn Erik Pedersen
2016-08-04 20:41:30 +02:00
parent f0b91852ea
commit d572071784
3 changed files with 43 additions and 10 deletions

View File

@@ -14,10 +14,10 @@ import (
"github.com/spf13/hugo/helpers"
"github.com/spf13/hugo/hugofs"
"github.com/spf13/hugo/source"
jww "github.com/spf13/jwalterweatherman"
"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
jww "github.com/spf13/jwalterweatherman"
"github.com/stretchr/testify/require"
)
func init() {
@@ -52,7 +52,7 @@ func TestMultiSites(t *testing.T) {
sites := createMultiTestSites(t)
err := sites.Build(BuildCfg{skipRender: true})
err := sites.Build(BuildCfg{})
if err != nil {
t.Fatalf("Failed to build sites: %s", err)
@@ -126,6 +126,11 @@ func TestMultiSites(t *testing.T) {
assert.Equal(t, "fr", frenchPage.Lang())
}
languageRedirect := readDestination(t, "public/index.html")
// French is the main content language
require.True(t, strings.Contains(languageRedirect, "0; url=http://example.com/blog/fr"), languageRedirect)
}
func TestMultiSitesRebuild(t *testing.T) {
@@ -498,7 +503,7 @@ func readFileFromFs(t *testing.T, fs afero.Fs, filename string) string {
// Print some debug info
root := strings.Split(filename, helpers.FilePathSeparator)[0]
afero.Walk(fs, root, func(path string, info os.FileInfo, err error) error {
if !info.IsDir() {
if info != nil && !info.IsDir() {
fmt.Println(" ", path)
}