From 5f91c26443fb4182a5b8581d6e62d03370c67876 Mon Sep 17 00:00:00 2001
From: crystal <crystal@noreply.codeberg.org>
Date: Thu, 12 Jan 2023 18:20:00 -0700
Subject: [PATCH] allow raw domain to serve files from branches with custom
 domains

---
 server/handler/try.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/server/handler/try.go b/server/handler/try.go
index 5a09b91..5c65138 100644
--- a/server/handler/try.go
+++ b/server/handler/try.go
@@ -20,7 +20,7 @@ func tryUpstream(ctx *context.Context, giteaClient *gitea.Client,
 	canonicalDomainCache cache.SetGetKey,
 ) {
 	// check if a canonical domain exists on a request on MainDomain
-	if strings.HasSuffix(trimmedHost, mainDomainSuffix) {
+	if strings.HasSuffix(trimmedHost, mainDomainSuffix) && !options.ServeRaw {
 		canonicalDomain, _ := options.CheckCanonicalDomain(giteaClient, "", mainDomainSuffix, canonicalDomainCache)
 		if !strings.HasSuffix(strings.SplitN(canonicalDomain, "/", 2)[0], mainDomainSuffix) {
 			canonicalPath := ctx.Req.RequestURI