Skip to content

Commit 8ef5bb3

Browse files
committed
fix: accept 'ref' as fallback for 'doc' query parameter
Keep backward compatibility for external integrations that still use the old ?ref= parameter while recommending ?doc= to avoid privacy extensions blocking.
1 parent d3e7c99 commit 8ef5bb3

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

backend/internal/presentation/api/documents/handler.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,11 @@ type FindOrCreateDocumentResponse struct {
492492
func (h *Handler) HandleFindOrCreateDocument(w http.ResponseWriter, r *http.Request) {
493493
ctx := r.Context()
494494

495-
// Get reference from query parameter (renamed from "ref" to "doc" to avoid ClearURLs blocking)
495+
// "doc" is the primary parameter; "ref" is accepted as fallback for backward compatibility
496496
ref := r.URL.Query().Get("doc")
497+
if ref == "" {
498+
ref = r.URL.Query().Get("ref")
499+
}
497500
if ref == "" {
498501
logger.Logger.Warn("Find or create request missing doc parameter",
499502
"remote_addr", r.RemoteAddr)

backend/internal/presentation/api/proxy/handler.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,11 @@ func (h *Handler) HandleProxy(w http.ResponseWriter, r *http.Request) {
8585
startTime := time.Now()
8686
requestID := getRequestID(r.Context())
8787

88-
// Extract parameters
88+
// "doc" is the primary parameter; "ref" is accepted as fallback for backward compatibility
8989
docID := r.URL.Query().Get("doc")
90+
if docID == "" {
91+
docID = r.URL.Query().Get("ref")
92+
}
9093
rawURL := r.URL.Query().Get("url")
9194

9295
// Validate required parameters

backend/internal/presentation/handlers/oembed.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,11 @@ func HandleOEmbed(baseURL string) http.HandlerFunc {
4444
return
4545
}
4646

47-
// Extract doc ID from query parameters
47+
// "doc" is the primary parameter; "ref" is accepted as fallback for backward compatibility
4848
docID := parsedURL.Query().Get("doc")
49+
if docID == "" {
50+
docID = parsedURL.Query().Get("ref")
51+
}
4952
if docID == "" {
5053
logger.Logger.Warn("oEmbed request missing doc parameter in url",
5154
"url", urlParam,

backend/pkg/web/middleware_embed.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ func EmbedDocumentMiddleware(
5050
return
5151
}
5252

53-
// Get doc ID from query parameter
53+
// "doc" is the primary parameter; "ref" is accepted as fallback for backward compatibility
5454
docID := r.URL.Query().Get("doc")
5555
if docID == "" {
56-
// No doc parameter, let SPA handle it
56+
docID = r.URL.Query().Get("ref")
57+
}
58+
if docID == "" {
5759
next.ServeHTTP(w, r)
5860
return
5961
}

backend/pkg/web/static.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ func serveIndexTemplate(w http.ResponseWriter, r *http.Request, file fs.File, ba
9797

9898
func generateMetaTags(r *http.Request, baseURL string, signatureRepo SignatureRepository) string {
9999
docID := r.URL.Query().Get("doc")
100+
if docID == "" {
101+
docID = r.URL.Query().Get("ref")
102+
}
100103
if docID == "" {
101104
return ""
102105
}

0 commit comments

Comments
 (0)