shithub: hugo

Download patch

ref: 5e0a16ea21c4467e809d6369bd1971661713f068
parent: 029a3ae79e9f1d53a3cbcf577ce65dbf9e4cf6ca
author: Austin Ziegler <austin@zieglers.ca>
date: Fri Dec 26 06:55:53 EST 2014

Fix a crash for ref page#anchor.

- Remove an improperly shadowed variable.
- Fixes #741.

--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -160,8 +160,6 @@
 	var link string = ""
 
 	if refUrl.Path != "" {
-		var target *Page
-
 		for _, page := range []*Page(*s.Pages) {
 			if page.Source.Path() == refUrl.Path || page.Source.LogicalName() == refUrl.Path {
 				target = page
@@ -187,7 +185,7 @@
 	if refUrl.Fragment != "" {
 		link = link + "#" + refUrl.Fragment
 
-		if refUrl.Path != "" {
+		if refUrl.Path != "" && target != nil {
 			link = link + ":" + target.UniqueId()
 		} else if page != nil {
 			link = link + ":" + page.UniqueId()
--