shithub: hugo

Download patch

ref: fa71f6c11e30192316c03522bc8f2f49abe461d7
parent: e3daa359ecbe77e8ad7a6ec5e76e634c6530e599
author: bep <[email protected]>
date: Tue Feb 10 14:13:45 EST 2015

Make # survice Url cleaning

To enable anchors in Urls.

Fixes #888

--- a/helpers/path.go
+++ b/helpers/path.go
@@ -92,7 +92,7 @@
 	target := make([]rune, 0, len(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)
 		}
 	}
--- a/hugolib/menu_test.go
+++ b/hugolib/menu_test.go
@@ -50,6 +50,10 @@
 	name = "Tax RSS"
     url = "/two/key.xml"
 	identifier="xml"
+[[menu.hash]]
+   name = "Tax With #"
+   url = "/resource#anchor"
+   identifier="hash"
 [[menu.unicode]]
    name = "Unicode Russian"
    identifier = "unicode-russian"
@@ -260,6 +264,18 @@
 
 	}
 
+}
+
+// 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