Go back to lowercase slugs. Also, use MakePathToLower in TestMakeToLower.
authorJakub Turski <yacoob@gmail.com>
Wed, 3 Sep 2014 19:05:44 +0000 (20:05 +0100)
committerspf13 <steve.francia@gmail.com>
Mon, 8 Sep 2014 15:42:36 +0000 (11:42 -0400)
go fmt

helpers/helpers_test.go
helpers/path.go
helpers/url.go

index 6d3993be413fe469d1db3025ddfb4bdec0c36672..ad041cc0a70fb45d76726c67e54ca0826b6efa3c 100644 (file)
@@ -1,8 +1,9 @@
 package helpers
 
 import (
-       "github.com/stretchr/testify/assert"
        "testing"
+
+       "github.com/stretchr/testify/assert"
 )
 
 func TestPretty(t *testing.T) {
@@ -45,8 +46,8 @@ func TestMakePath(t *testing.T) {
                {"fOO,bar:foo%bAR", "fOObarfoobAR"},
                {"FOo/BaR.html", "FOo/BaR.html"},
                {"трям/трям", "трям/трям"},
-               {"은행","은행"},
-               {"Банковский кассир","Банковский-кассир"},
+               {"은행", "은행"},
+               {"Банковский кассир", "Банковский-кассир"},
        }
 
        for _, test := range tests {
@@ -63,15 +64,16 @@ func TestMakeToLower(t *testing.T) {
                expected string
        }{
                {"  foo bar  ", "foo-bar"},
+               {"  Foo Bar  ", "foo-bar"},
                {"foo.bar/foo_bar-foo", "foo.bar/foo_bar-foo"},
                {"foo,bar:foo%bar", "foobarfoobar"},
                {"foo/bar.html", "foo/bar.html"},
                {"трям/трям", "трям/трям"},
-               {"은행","은행"},
+               {"은행", "은행"},
        }
 
        for _, test := range tests {
-               output := MakePath(test.input)
+               output := MakePathToLower(test.input)
                if output != test.expected {
                        t.Errorf("Expected %#v, got %#v\n", test.expected, output)
                }
@@ -84,6 +86,7 @@ func TestUrlize(t *testing.T) {
                expected string
        }{
                {"  foo bar  ", "foo-bar"},
+               {"Foo And BAR", "foo-and-bar"},
                {"foo.bar/foo_bar-foo", "foo.bar/foo_bar-foo"},
                {"foo,bar:foo%bar", "foobarfoobar"},
                {"foo/bar.html", "foo/bar.html"},
index 2f63c718cd134fc9bda7b43d70ba16fbda279dfc..7f99bfca02e651a484b0c9209c72bbd174405a51 100644 (file)
@@ -40,7 +40,7 @@ func MakePath(s string) string {
 // and transformed to lower case.
 // E.g. Social Media -> social-media
 func MakePathToLower(s string) string {
-        return UnicodeSanitize(strings.ToLower(strings.Replace(strings.TrimSpace(s), " ", "-", -1)))
+       return UnicodeSanitize(strings.ToLower(strings.Replace(strings.TrimSpace(s), " ", "-", -1)))
 }
 
 func MakeTitle(inpath string) string {
index 04883205859b9a7a8481e35287af2fd6f9f1c865..afdf7490e5c300c9effa5845a5d5b9ad2d68ec7f 100644 (file)
@@ -35,7 +35,7 @@ func SanitizeUrl(in string) string {
 //     uri: Vim (text editor)
 //     urlize: vim-text-editor
 func Urlize(uri string) string {
-       sanitized := MakePath(uri)
+       sanitized := MakePathToLower(uri)
 
        // escape unicode letters
        parsedUri, err := url.Parse(sanitized)