Open platform to collect and prioritize feedback
fix: include full url to og:url (#384)
Guilherme Oenning637937d55b0e
diff --git a/app/pkg/web/context.go b/app/pkg/web/context.goindex ccfdbb57b..7f30633d8 100644--- a/app/pkg/web/context.go+++ b/app/pkg/web/context.go@@ -221,7 +221,7 @@ func (ctx *Context) Failure(err error) error {user = fmt.Sprintf("%s (%d)", ctx.User().Name, ctx.User().ID)}- url := ctx.BaseURL() + ctx.Request.RequestURI+ url := ctx.CurrentURL()message := fmt.Sprintf("URL: %s\nTenant: %s\nUser: %s\n%s", url, tenant, user, err.Error())ctx.Logger().Errorf(log.Red(message))ctx.Render(http.StatusInternalServerError, "500.html", Props{@@ -359,7 +359,7 @@ func (ctx *Context) ActiveTransaction() *dbx.Trx {return ctx.Get(transactionContextKey).(*dbx.Trx)}-//BaseURL returns base URL as string+//BaseURL returns base URLfunc (ctx *Context) BaseURL() string {protocol := "http"if ctx.Request.TLS != nil || ctx.Request.Header.Get("X-Forwarded-Proto") == "https" {@@ -368,6 +368,11 @@ func (ctx *Context) BaseURL() string {return protocol + "://" + ctx.Request.Host}+//CurrentURL returns complete current URL+func (ctx *Context) CurrentURL() string {+ return ctx.BaseURL() + ctx.Request.RequestURI+}+//TenantBaseURL returns base URL for a given tenantfunc (ctx *Context) TenantBaseURL(tenant *models.Tenant) string {if env.IsSingleHostMode() {diff --git a/app/pkg/web/context_test.go b/app/pkg/web/context_test.goindex 5b4b77a6f..43b01f2ed 100644--- a/app/pkg/web/context_test.go+++ b/app/pkg/web/context_test.go@@ -45,6 +45,15 @@ func TestBaseURL(t *testing.T) {Expect(ctx.BaseURL()).Equals("http://demo.test.fider.io:3000")}+func TestCurrentURL(t *testing.T) {+ RegisterT(t)++ ctx := newGetContext(nil)+ ctx.Request.RequestURI = "/resource?id=23"++ Expect(ctx.CurrentURL()).Equals("http://demo.test.fider.io:3000/resource?id=23")+}+func TestTenantURL(t *testing.T) {RegisterT(t)diff --git a/app/pkg/web/renderer.go b/app/pkg/web/renderer.goindex 6e6736fae..7ab73235b 100644--- a/app/pkg/web/renderer.go+++ b/app/pkg/web/renderer.go@@ -120,6 +120,7 @@ func (r *Renderer) Render(w io.Writer, name string, props Props, ctx *Context) em["system"] = r.settingsm["baseURL"] = ctx.BaseURL()+ m["currentURL"] = ctx.CurrentURL()m["tenant"] = ctx.Tenant()m["auth"] = Map{"endpoint": ctx.AuthEndpoint(),diff --git a/views/base.html b/views/base.htmlindex 1153de130..533902fe6 100644--- a/views/base.html+++ b/views/base.html@@ -10,28 +10,8 @@<meta property="og:title" content="{{ .__Title }}" /><meta property="og:description" content="{{ .__Description }}" /><meta property="og:type" content="website" />- <meta property="og:url" content="{{ .baseURL }}" />+ <meta property="og:url" content="{{ .currentURL }}" /><meta property="og:image" content="{{ .__logo }}">- <style rel="stylesheet" nonce="{{ .__ContextID }}">- /* .gm-primary {- color: red;- }-- .gm-primary-hover:hover {- color: red;- }-- .gs-planned {- background-color: pink;- }-- a {- color: red;- }- a:hover {- color: red;- } */- </style></head><body><noscript class="ui container">