Skip to content

Commit e8c2211

Browse files
authored
Merge pull request #38 from IntegerAlex/fix#16
Fixed #16
2 parents 0dd6ba2 + ca53652 commit e8c2211

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lib/httpParser.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@ async function httpParser(request) {
1919
req.path = requestLine[1]; // e.g., "/path"
2020
req.version = requestLine[2]; // e.g., "HTTP/1.1"
2121

22-
// Step 3: Handle GET requests (no body expected)
23-
if (req.method === "GET") {
24-
req.query = queryParser(req.path); // Parse query string for GET requests
25-
return req; // Return immediately for GET requests
26-
}
22+
// Step 3: Handle GET requests (expect a query string)
23+
req.query = queryParser(req.path); // Parse query string for GET requests
24+
req.path = req.path.split("?")[0]; // Remove query string from path
25+
2726

28-
// Step 4: Handle POST requests (expect a body)
27+
// Step 4: Handle POST requests (expect a body)
2928
if (req.method === "POST") {
3029
// Now we need to parse the body, which is in `bodyPart`
3130
const position = 0; // Start at position 0 of the bodyPart

0 commit comments

Comments
 (0)