Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
This requires a couple of changes before it can be approved. You've done a great job setting up the server structure, but there are two critical issues that break its functionality.
First, the base URL provided to the URL constructor in src/createServer.js is invalid. It uses a backslash (http:\\...) which will cause the server to crash. This should be corrected to use forward slashes: http://${req.headers.host}.
Second, the pathname parsing doesn't correctly handle doubled slashes as required. When a path like //hello is split by /, it produces empty strings. Your current filter logic doesn't remove these, leading to an incorrect parts array. Please adjust your filter to correctly handle these empty strings.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
src/createServer.js
Outdated
| .slice(1) | ||
| .filter((part) => part !== '/'); |
There was a problem hiding this comment.
This logic for parsing the pathname doesn't correctly handle doubled slashes. slice(1) only removes the first element, which is not sufficient for paths starting with //. Additionally, the filter condition part !== '/' is incorrect, as split('/') produces empty strings for consecutive slashes, not '/' characters.
src/createServer.js
Outdated
| const server = http.createServer((req, res) => { | ||
| res.setHeader('Content-Type', 'application/json'); | ||
|
|
||
| const url = new URL(req.url, `http:\\${req.headers.host}`); |
There was a problem hiding this comment.
The base URL provided to the URL constructor is not correctly formatted. A backslash (\) is used as a separator, but the standard requires forward slashes (//) after the protocol. The correct format is http://${req.headers.host}.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Excellent work! I am approving this submission. You've successfully addressed all the feedback from the previous review. The base URL for the URL constructor is now correct, and the logic for parsing the pathname properly handles double slashes by filtering out the empty strings. The server now meets all the requirements. Great job!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.