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)
This commit is contained in:
박상용 2025-08-12 21:30:51 +09:00
parent 1ebe06f51e
commit f20113ea2c

View file

@ -1106,7 +1106,18 @@ class HttpCli(object):
status: int = 200, status: int = 200,
use302: bool = False, use302: bool = False,
) -> bool: ) -> bool:
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 vp = self.args.SRS + vpath
else:
if vpath.startswith("/"):
vp = vpath
else:
vp = "/" + vpath if vpath else "/"
html = self.j2s( html = self.j2s(
"msg", "msg",
h2='<a href="{}">{} {}</a>'.format( h2='<a href="{}">{} {}</a>'.format(