mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-14 20:33:59 +02:00
Add config option "disablePathToLower"
Enabling this prevents lowercasing of the path/url. Fixes #557
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
49fe04c0bd
commit
52d94fa675
@@ -42,7 +42,10 @@ func TestMakePath(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMakePathToLower(t *testing.T) {
|
||||
func TestMakePathSanitized(t *testing.T) {
|
||||
viper.Reset()
|
||||
defer viper.Reset()
|
||||
|
||||
tests := []struct {
|
||||
input string
|
||||
expected string
|
||||
@@ -54,8 +57,34 @@ func TestMakePathToLower(t *testing.T) {
|
||||
{"трям/трям", "трям/трям"},
|
||||
{"은행", "은행"},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
output := MakePathToLower(test.input)
|
||||
output := MakePathSanitized(test.input)
|
||||
if output != test.expected {
|
||||
t.Errorf("Expected %#v, got %#v\n", test.expected, output)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestMakePathSanitizedDisablePathToLower(t *testing.T) {
|
||||
viper.Reset()
|
||||
defer viper.Reset()
|
||||
viper.Set("DisablePathToLower", true)
|
||||
|
||||
tests := []struct {
|
||||
input string
|
||||
expected string
|
||||
}{
|
||||
{" FOO bar ", "FOO-bar"},
|
||||
{"Foo.Bar/fOO_bAr-Foo", "Foo.Bar/fOO_bAr-Foo"},
|
||||
{"FOO,bar:Foo%Bar", "FOObarFooBar"},
|
||||
{"foo/BAR.HTML", "foo/BAR.HTML"},
|
||||
{"трям/трям", "трям/трям"},
|
||||
{"은행", "은행"},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
output := MakePathSanitized(test.input)
|
||||
if output != test.expected {
|
||||
t.Errorf("Expected %#v, got %#v\n", test.expected, output)
|
||||
}
|
||||
|
Reference in New Issue
Block a user