From f20113ea2c69ede46b916bafdf6eae89c61ae37e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EC=83=81=EC=9A=A9?= Date: Tue, 12 Aug 2025 21:30:51 +0900 Subject: [PATCH] Simplify reverse proxy path handling in redirect() Remove redundant SRS check since SRS paths always start with SR. The first condition (SRS) is redundant because SRS = SR + "/", so any path starting with SRS will also start with SR. Closes #306(9001/copyparty#306) --- copyparty/httpcli.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 72bff45e..795e111d 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -1106,7 +1106,18 @@ class HttpCli(object): status: int = 200, use302: bool = False, ) -> bool: - vp = self.args.SRS + vpath + if self.args.R: + if vpath.startswith(self.args.SR): + vp = vpath + elif vpath.startswith("/"): + vp = self.args.SR + vpath + else: + vp = self.args.SRS + vpath + else: + if vpath.startswith("/"): + vp = vpath + else: + vp = "/" + vpath if vpath else "/" html = self.j2s( "msg", h2='{} {}'.format(