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.
This commit is contained in:
Matt Baer 2019-07-22 14:16:44 -04:00
parent f6f116d672
commit 4faf41ae7f
1 changed files with 4 additions and 0 deletions

View File

@ -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 + "/"
}