From 43dec6032a4e3315804f126072c8892f328ce108 Mon Sep 17 00:00:00 2001 From: miyuko Date: Fri, 19 Jun 2026 02:44:58 +0100 Subject: [PATCH] Match on the full request URL when applying headers. Fixes: https://codeberg.org/git-pages/git-pages/issues/206 --- src/main.go | 2 +- src/pages.go | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main.go b/src/main.go index e1d63d1..3d7606b 100644 --- a/src/main.go +++ b/src/main.go @@ -45,7 +45,7 @@ func configureFeatures(ctx context.Context) (err error) { for _, feature := range config.Features { switch feature { // Work-in-progress features: - case "preview", "expiration": + case "preview", "expiration", "absolute-headers": // Permanently unstable features: case "codeberg-pages-compat", "relaxed-idna": // Stabilized features: diff --git a/src/pages.go b/src/pages.go index 0d48b5a..d481e87 100644 --- a/src/pages.go +++ b/src/pages.go @@ -446,7 +446,11 @@ func getPage(w http.ResponseWriter, r *http.Request) error { w.Header().Set("Content-Type", *entry.ContentType) } - customHeaders, err := ApplyHeaderRules(manifest, &url.URL{Path: entryPath}) + headersMatchURL := &url.URL{Path: entryPath} + if config.Feature("absolute-headers") { + headersMatchURL = (&url.URL{Host: r.Host}).ResolveReference(r.URL) + } + customHeaders, err := ApplyHeaderRules(manifest, headersMatchURL) if err != nil { // This is an "internal server error" from an HTTP point of view, but also // either an issue with the site or a misconfiguration from our point of view.