Make # survice Url cleaning

To enable anchors in Urls.

Fixes #888
This commit is contained in:
bep 2015-02-10 19:13:45 +01:00
parent e3daa359ec
commit fa71f6c11e
2 changed files with 17 additions and 1 deletions

View file

@ -92,7 +92,7 @@ func UnicodeSanitize(s string) string {
target := make([]rune, 0, len(source)) target := make([]rune, 0, len(source))
for _, r := range source { for _, r := range source {
if unicode.IsLetter(r) || unicode.IsDigit(r) || r == '.' || r == '/' || r == '_' || r == '-' { if unicode.IsLetter(r) || unicode.IsDigit(r) || r == '.' || r == '/' || r == '_' || r == '-' || r == '#' {
target = append(target, r) target = append(target, r)
} }
} }

View file

@ -50,6 +50,10 @@ const (
name = "Tax RSS" name = "Tax RSS"
url = "/two/key.xml" url = "/two/key.xml"
identifier="xml" identifier="xml"
[[menu.hash]]
name = "Tax With #"
url = "/resource#anchor"
identifier="hash"
[[menu.unicode]] [[menu.unicode]]
name = "Unicode Russian" name = "Unicode Russian"
identifier = "unicode-russian" identifier = "unicode-russian"
@ -262,6 +266,18 @@ func TestPageMenu(t *testing.T) {
} }
// issue #888
func TestMenuWithHashInUrl(t *testing.T) {
ts := setupMenuTests(t, MENU_PAGE_SOURCES)
defer resetMenuTestState(ts)
me := ts.findTestMenuEntryById("hash", "hash")
assert.NotNil(t, me)
assert.Equal(t, "/Zoo/resource/#anchor", me.Url)
}
// issue #719 // issue #719
func TestMenuWithUnicodeUrls(t *testing.T) { func TestMenuWithUnicodeUrls(t *testing.T) {
for _, uglyUrls := range []bool{true, false} { for _, uglyUrls := range []bool{true, false} {