From 4faf41ae7ffd8aafa7167c0ec2e0cfe218547cfb Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Mon, 22 Jul 2019 14:16:44 -0400 Subject: [PATCH] Log missing hostName in Collection.RedirectingCanonicalURL This is the crucial part where the hostName is needed for federation and API clients. This change at least lets us know when we mess up like this so the issue is easier to catch in the future. --- collections.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/collections.go b/collections.go index 1a8ceca..d874e3e 100644 --- a/collections.go +++ b/collections.go @@ -211,6 +211,10 @@ func (c *Collection) DisplayCanonicalURL() string { } func (c *Collection) RedirectingCanonicalURL(isRedir bool) string { + if c.hostName == "" { + // If this is true, the human programmers screwed up. So ask for a bug report and fail, fail, fail + log.Error("[PROGRAMMER ERROR] WARNING: Collection.hostName is empty! Federation and many other things will fail! If you're seeing this in the wild, please report this bug and let us know what you were doing just before this: https://github.com/writeas/writefreely/issues/new?template=bug_report.md") + } if isSingleUser { return c.hostName + "/" }