From bf3074a54dedf286983127f70eaef054b138e655 Mon Sep 17 00:00:00 2001 From: Jan-Lukas Else Date: Fri, 19 Nov 2021 23:30:36 +0100 Subject: [PATCH] Fix debug messages and webmention to root without path --- utils.go | 3 +++ webmentionVerification.go | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/utils.go b/utils.go index e37497c..b78588c 100644 --- a/utils.go +++ b/utils.go @@ -304,5 +304,8 @@ func doHandlerRequest(req *http.Request, handler http.Handler) (*http.Response, client := &http.Client{ Transport: &handlerRoundTripper{handler: handler}, } + if req.URL.Path == "" { + req.URL.Path = "/" + } return client.Do(req) } diff --git a/webmentionVerification.go b/webmentionVerification.go index 2e266ea..9142269 100644 --- a/webmentionVerification.go +++ b/webmentionVerification.go @@ -75,7 +75,7 @@ func (a *goBlog) verifyMention(m *mention) error { // Check if target has a valid status code if targetResp.StatusCode != http.StatusOK { if a.cfg.Debug { - a.debug("Webmention for unknown path: %s\n", m.Target) + a.debug(fmt.Sprintf("Webmention for unknown path: %s", m.Target)) } return a.db.deleteWebmention(m) } @@ -106,7 +106,7 @@ func (a *goBlog) verifyMention(m *mention) error { // Check if source has a valid status code if sourceResp.StatusCode != http.StatusOK { if a.cfg.Debug { - a.debug("Delete webmention because source doesn't have valid status code: %s\n", m.Source) + a.debug(fmt.Sprintf("Delete webmention because source doesn't have valid status code: %s", m.Source)) } return a.db.deleteWebmention(m) } @@ -121,7 +121,7 @@ func (a *goBlog) verifyMention(m *mention) error { _ = sourceResp.Body.Close() if err != nil { if a.cfg.Debug { - a.debug("Delete webmention because verifying %s threw error: %s\n", m.Source, err.Error()) + a.debug(fmt.Sprintf("Delete webmention because verifying %s threw error: %s", m.Source, err.Error())) } return a.db.deleteWebmention(m) } @@ -135,7 +135,7 @@ func (a *goBlog) verifyMention(m *mention) error { // Update or insert webmention if a.db.webmentionExists(m) { if a.cfg.Debug { - a.debug("Update webmention: %s => %s\n", m.Source, m.Target) + a.debug(fmt.Sprintf("Update webmention: %s => %s", m.Source, m.Target)) } // Update webmention err = a.db.updateWebmention(m, newStatus)