Skip to content

Commit 8aa5ead

Browse files
committed
Merge branch 'Add_form_capability' into my-main
2 parents ab66e08 + 14a5b4a commit 8aa5ead

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

adafruit_httpserver.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,22 @@ def __init__(
7575
except ValueError as exc:
7676
raise ValueError("Unparseable raw_request: ", raw_request) from exc
7777

78+
# If ? is found in path, strip form data for matching route
79+
try:
80+
idx = self.path.index('?')
81+
except ValueError:
82+
idx = len(self.path)
83+
self.form = self.path[:idx]
84+
7885
def __hash__(self) -> int:
7986
return hash(self.method) ^ hash(self.path)
8087

8188
def __eq__(self, other: "_HTTPRequest") -> bool:
82-
return self.method == other.method and self.path == other.path
89+
# Match path found in decorator with form from the actual request,
90+
return self.method == other.method and self.path == other.form
8391

8492
def __repr__(self) -> str:
85-
return f"_HTTPRequest(path={repr(self.path)}, method={repr(self.method)})"
93+
return f"_HTTPRequest(path={repr(self.path)}, method={repr(self.method)}, form={repr(self.form)})"
8694

8795

8896
class MIMEType:

0 commit comments

Comments
 (0)