Skip to content

Commit b42e836

Browse files
committed
Fix route matching with form data
1 parent 4055162 commit b42e836

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

adafruit_httpserver.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,14 @@ def __init__(
7676
raise ValueError("Unparseable raw_request: ", raw_request) from exc
7777

7878
# 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]
79+
self.form = self.path.split('?')[0]
8480

8581
def __hash__(self) -> int:
86-
return hash(self.method) ^ hash(self.path)
82+
return hash(self.method) ^ hash(self.form)
8783

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

9288
def __repr__(self) -> str:
9389
return f"_HTTPRequest(path={repr(self.path)}, method={repr(self.method)}, form={repr(self.form)})"

0 commit comments

Comments
 (0)