Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2015-06-16 20:25:48 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2015-06-16 20:25:48 +0300
commit4b7c1342fd6d7eea216ff9de22f94a195d620414 (patch)
treec8f3b9450314a93d718852c78e8a1b01359b2283 /helpers
parent847ad36e45bc3d2bd486a33144aa7dccfa5aacb3 (diff)
Make removal of accents in taxonomy and section paths optional
And default off. Fixes #1180
Diffstat (limited to 'helpers')
-rw-r--r--helpers/path.go13
-rw-r--r--helpers/path_test.go6
2 files changed, 15 insertions, 4 deletions
diff --git a/helpers/path.go b/helpers/path.go
index 5e5e3fa89..0c601a868 100644
--- a/helpers/path.go
+++ b/helpers/path.go
@@ -99,9 +99,16 @@ func UnicodeSanitize(s string) string {
}
}
- // remove accents - see https://blog.golang.org/normalization
- t := transform.Chain(norm.NFD, transform.RemoveFunc(isMn), norm.NFC)
- result, _, _ := transform.String(t, string(target))
+ var result string
+
+ if viper.GetBool("RemovePathAccents") {
+ // remove accents - see https://blog.golang.org/normalization
+ t := transform.Chain(norm.NFD, transform.RemoveFunc(isMn), norm.NFC)
+ result, _, _ = transform.String(t, string(target))
+ } else {
+ result = string(target)
+ }
+
return result
return string(target)
diff --git a/helpers/path_test.go b/helpers/path_test.go
index 3fdb94a4f..5cf863b6c 100644
--- a/helpers/path_test.go
+++ b/helpers/path_test.go
@@ -17,6 +17,10 @@ import (
)
func TestMakePath(t *testing.T) {
+ viper.Reset()
+ defer viper.Reset()
+ viper.Set("RemovePathAccents", true)
+
tests := []struct {
input string
expected string
@@ -717,7 +721,7 @@ func TestGetTempDir(t *testing.T) {
{testDir + "FOo/BaR.html", dir + testDir + "FOo/BaR.html" + FilePathSeparator},
{testDir + "трям/трям", dir + testDir + "трям/трям" + FilePathSeparator},
{testDir + "은행", dir + testDir + "은행" + FilePathSeparator},
- {testDir + "Банковский кассир", dir + testDir + "Банковскии-кассир" + FilePathSeparator},
+ {testDir + "Банковский кассир", dir + testDir + "Банковский-кассир" + FilePathSeparator},
}
for _, test := range tests {