Read portal SEO origin from request context

SNI middleware already stores scheme://host; SEOFromRequest
no longer takes a base URL or re-strips the path. Expose
context helpers and drop the obsolete strip tests.

Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
Émile Ré
2026-07-22 12:19:25 +02:00
parent 9ee0df4d3f
commit 52310dbf65
5 changed files with 57 additions and 115 deletions

View File

@@ -21,7 +21,6 @@
package complianceportal
import (
"context"
"errors"
"net/http"
"net/url"
@@ -115,21 +114,15 @@ func NewSNIMiddleware(visitorSvc *visitor.Service) func(next http.Handler) http.
// Origin only — consumers append their own paths (SEO, sitemap,
// robots, brand assets, OAuth). Including r.URL.Path here would
// duplicate the route (e.g. /fr/documents/fr/documents).
baseURL := &url.URL{
baseURL := (&url.URL{
Host: r.Host,
Scheme: "https",
}
baseURLString := baseURL.String()
ctx = context.WithValue(
ctx,
compliancePortalBaseURLKey,
&baseURLString,
)
}).String()
ctx = ContextWithCompliancePortalBaseURL(ctx, baseURL)
r = r.WithContext(ctx)
if compliancePage.Active {
ctx = context.WithValue(ctx, compliancePortalKey, compliancePage)
ctx = ContextWithCompliancePortal(ctx, compliancePage)
next.ServeHTTP(w, r.WithContext(ctx))
return