From 4bae8b04aadd72d298bf2dd1bb1430806bf2869c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Sat, 29 Dec 2018 10:14:37 +0100 Subject: Revert " Fix handling of taxonomy terms containing slashes" See #4090 See #5571 This reverts commit fff132537b4094221f4f099e2251f3cda613060f. --- helpers/path.go | 11 ----------- helpers/path_test.go | 33 --------------------------------- 2 files changed, 44 deletions(-) (limited to 'helpers') diff --git a/helpers/path.go b/helpers/path.go index 2d0e8aa64..bf7e3bf99 100644 --- a/helpers/path.go +++ b/helpers/path.go @@ -77,17 +77,6 @@ func (filepathBridge) Separator() string { var fpb filepathBridge -// segmentReplacer replaces some URI-reserved characters in a path segments. -var segmentReplacer = strings.NewReplacer("/", "-", "#", "-") - -// MakeSegment returns a copy of string s that is appropriate for a path -// segment. MakeSegment is similar to MakePath but disallows the '/' and -// '#' characters because of their reserved meaning in URIs. -func (p *PathSpec) MakeSegment(s string) string { - return p.MakePathSanitized(segmentReplacer.Replace(s)) - -} - // MakePath takes a string with any characters and replace it // so the string could be used in a path. // It does so by creating a Unicode-sanitized string, with the spaces replaced, diff --git a/helpers/path_test.go b/helpers/path_test.go index a1110b094..c249a519d 100644 --- a/helpers/path_test.go +++ b/helpers/path_test.go @@ -36,39 +36,6 @@ import ( "github.com/spf13/viper" ) -func TestMakeSegment(t *testing.T) { - tests := []struct { - input string - expected string - }{ - {" FOO bar ", "foo-bar"}, - {"Foo.Bar/fOO_bAr-Foo", "foo.bar-foo_bar-foo"}, - {"FOO,bar:FooBar", "foobarfoobar"}, - {"foo/BAR.HTML", "foo-bar.html"}, - {"трям/трям", "трям-трям"}, - {"은행", "은행"}, - {"Say What??", "say-what"}, - {"Your #1 Fan", "your-1-fan"}, - {"Red & Blue", "red-blue"}, - {"double//slash", "double-slash"}, - {"triple///slash", "triple-slash"}, - {"-my/way-", "my-way"}, - } - - for _, test := range tests { - v := newTestCfg() - - l := langs.NewDefaultLanguage(v) - p, err := NewPathSpec(hugofs.NewMem(v), l) - require.NoError(t, err) - - output := p.MakeSegment(test.input) - if output != test.expected { - t.Errorf("Expected %#v, got %#v\n", test.expected, output) - } - } -} - func TestMakePath(t *testing.T) { tests := []struct { input string -- cgit v1.2.3