Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4faf41a

Browse files
committed
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.
1 parent f6f116d commit 4faf41a

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

collections.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ func (c *Collection) DisplayCanonicalURL() string {
211211
}
212212

213213
func (c *Collection) RedirectingCanonicalURL(isRedir bool) string {
214+
if c.hostName == "" {
215+
// If this is true, the human programmers screwed up. So ask for a bug report and fail, fail, fail
216+
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")
217+
}
214218
if isSingleUser {
215219
return c.hostName + "/"
216220
}

0 commit comments

Comments
 (0)