diff options
author | Cameron Moore <[email protected]> | 2022-01-17 16:33:47 -0600 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2022-02-23 21:21:46 +0100 |
commit | 6407b2cd016f23bc4a63748feebfc8ecaccecca7 (patch) | |
tree | d3ee4c066c12c83ab2a26e035ec081be6bd0d633 /helpers/path_test.go | |
parent | 6ff39fd908242e32942ddd7f239ffd06cc8e7dda (diff) | |
download | hugo-6407b2cd016f23bc4a63748feebfc8ecaccecca7.tar.gz hugo-6407b2cd016f23bc4a63748feebfc8ecaccecca7.zip |
helpers: Allow hyphens in UnicodeSanitize
Improve handling of existing hyphens in input to UnicodeSanitize.
This commit accomplishes three things:
1. Explicitly allow hyphens
2. Avoid appending a hyphen if a preceeding hyphen is found
3. Avoid prepending a hyphen if a trailing hyphen is found
Fixes #7288
Diffstat (limited to 'helpers/path_test.go')
-rw-r--r-- | helpers/path_test.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/helpers/path_test.go b/helpers/path_test.go index 1d2dc1184..6a119a741 100644 --- a/helpers/path_test.go +++ b/helpers/path_test.go @@ -40,6 +40,10 @@ func TestMakePath(t *testing.T) { expected string removeAccents bool }{ + {"dot.slash/backslash\\underscore_pound#plus+hyphen-", "dot.slash/backslash\\underscore_pound#plus+hyphen-", true}, + {"abcXYZ0123456789", "abcXYZ0123456789", true}, + {"%20 %2", "%20-2", true}, + {"foo- bar", "foo-bar", true}, {" Foo bar ", "Foo-bar", true}, {"Foo.Bar/foo_Bar-Foo", "Foo.Bar/foo_Bar-Foo", true}, {"fOO,bar:foobAR", "fOObarfoobAR", true}, @@ -52,7 +56,7 @@ func TestMakePath(t *testing.T) { {"a%C3%B1ame", "a%C3%B1ame", false}, // Issue #1292 {"this+is+a+test", "this+is+a+test", false}, // Issue #1290 {"~foo", "~foo", false}, // Issue #2177 - + {"foo--bar", "foo--bar", true}, // Issue #7288 } for _, test := range tests { |