mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
parent
9d603ce88a
commit
36adb5fb88
2 changed files with 14 additions and 11 deletions
|
@ -96,7 +96,7 @@ func UnicodeSanitize(s string) string {
|
||||||
target := make([]rune, 0, len(source))
|
target := make([]rune, 0, len(source))
|
||||||
|
|
||||||
for _, r := range source {
|
for _, r := range source {
|
||||||
if unicode.IsLetter(r) || unicode.IsDigit(r) || r == '.' || r == '/' || r == '\\' || r == '_' || r == '-' || r == '#' {
|
if unicode.IsLetter(r) || unicode.IsDigit(r) || unicode.IsMark(r) || r == '.' || r == '/' || r == '\\' || r == '_' || r == '-' || r == '#' {
|
||||||
target = append(target, r)
|
target = append(target, r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,22 +19,25 @@ import (
|
||||||
func TestMakePath(t *testing.T) {
|
func TestMakePath(t *testing.T) {
|
||||||
viper.Reset()
|
viper.Reset()
|
||||||
defer viper.Reset()
|
defer viper.Reset()
|
||||||
viper.Set("RemovePathAccents", true)
|
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
input string
|
input string
|
||||||
expected string
|
expected string
|
||||||
|
removeAccents bool
|
||||||
}{
|
}{
|
||||||
{" Foo bar ", "Foo-bar"},
|
{" Foo bar ", "Foo-bar", true},
|
||||||
{"Foo.Bar/foo_Bar-Foo", "Foo.Bar/foo_Bar-Foo"},
|
{"Foo.Bar/foo_Bar-Foo", "Foo.Bar/foo_Bar-Foo", true},
|
||||||
{"fOO,bar:foo%bAR", "fOObarfoobAR"},
|
{"fOO,bar:foo%bAR", "fOObarfoobAR", true},
|
||||||
{"FOo/BaR.html", "FOo/BaR.html"},
|
{"FOo/BaR.html", "FOo/BaR.html", true},
|
||||||
{"трям/трям", "трям/трям"},
|
{"трям/трям", "трям/трям", true},
|
||||||
{"은행", "은행"},
|
{"은행", "은행", true},
|
||||||
{"Банковский кассир", "Банковскии-кассир"},
|
{"Банковский кассир", "Банковскии-кассир", true},
|
||||||
|
// Issue #1488
|
||||||
|
{"संस्कृत", "संस्कृत", false},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
viper.Set("RemovePathAccents", test.removeAccents)
|
||||||
output := MakePath(test.input)
|
output := MakePath(test.input)
|
||||||
if output != test.expected {
|
if output != test.expected {
|
||||||
t.Errorf("Expected %#v, got %#v\n", test.expected, output)
|
t.Errorf("Expected %#v, got %#v\n", test.expected, output)
|
||||||
|
|
Loading…
Reference in a new issue