Skip to content

Minor change that allows for regex replacements when using the revers… #1172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion proxy/http/server/reverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,12 @@ def handle_request(self, request: HttpParser) -> None:
pattern = re.compile(route)
if pattern.match(text_(request.path)):
self.choice = Url.from_bytes(
random.choice(self.reverse[route]),
self.reverse[route],
)
result = re.search(pattern, request.path.decode())
replacements = result.groups()[1:]
rewrite = request.path.decode().format(replacements)
self.choice.remainder = rewrite.encode()
break
assert self.choice and self.choice.hostname
port = self.choice.port or \
Expand Down