mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
Go back to lowercase slugs. Also, use MakePathToLower in TestMakeToLower.
go fmt
This commit is contained in:
parent
5dd3eaabee
commit
1684579127
3 changed files with 10 additions and 7 deletions
|
@ -1,8 +1,9 @@
|
||||||
package helpers
|
package helpers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPretty(t *testing.T) {
|
func TestPretty(t *testing.T) {
|
||||||
|
@ -63,6 +64,7 @@ func TestMakeToLower(t *testing.T) {
|
||||||
expected string
|
expected string
|
||||||
}{
|
}{
|
||||||
{" foo bar ", "foo-bar"},
|
{" foo bar ", "foo-bar"},
|
||||||
|
{" Foo Bar ", "foo-bar"},
|
||||||
{"foo.bar/foo_bar-foo", "foo.bar/foo_bar-foo"},
|
{"foo.bar/foo_bar-foo", "foo.bar/foo_bar-foo"},
|
||||||
{"foo,bar:foo%bar", "foobarfoobar"},
|
{"foo,bar:foo%bar", "foobarfoobar"},
|
||||||
{"foo/bar.html", "foo/bar.html"},
|
{"foo/bar.html", "foo/bar.html"},
|
||||||
|
@ -71,7 +73,7 @@ func TestMakeToLower(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
output := MakePath(test.input)
|
output := MakePathToLower(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)
|
||||||
}
|
}
|
||||||
|
@ -84,6 +86,7 @@ func TestUrlize(t *testing.T) {
|
||||||
expected string
|
expected string
|
||||||
}{
|
}{
|
||||||
{" foo bar ", "foo-bar"},
|
{" foo bar ", "foo-bar"},
|
||||||
|
{"Foo And BAR", "foo-and-bar"},
|
||||||
{"foo.bar/foo_bar-foo", "foo.bar/foo_bar-foo"},
|
{"foo.bar/foo_bar-foo", "foo.bar/foo_bar-foo"},
|
||||||
{"foo,bar:foo%bar", "foobarfoobar"},
|
{"foo,bar:foo%bar", "foobarfoobar"},
|
||||||
{"foo/bar.html", "foo/bar.html"},
|
{"foo/bar.html", "foo/bar.html"},
|
||||||
|
|
|
@ -35,7 +35,7 @@ func SanitizeUrl(in string) string {
|
||||||
// uri: Vim (text editor)
|
// uri: Vim (text editor)
|
||||||
// urlize: vim-text-editor
|
// urlize: vim-text-editor
|
||||||
func Urlize(uri string) string {
|
func Urlize(uri string) string {
|
||||||
sanitized := MakePath(uri)
|
sanitized := MakePathToLower(uri)
|
||||||
|
|
||||||
// escape unicode letters
|
// escape unicode letters
|
||||||
parsedUri, err := url.Parse(sanitized)
|
parsedUri, err := url.Parse(sanitized)
|
||||||
|
|
Loading…
Reference in a new issue