Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Great job setting up the server and handling the query parameters correctly! Your solution is very close, but it requires one adjustment before it can be approved.
The main issue is with how the URL pathname is parsed. The requirement is to ignore doubled slashes, but your current implementation using split('/') produces empty strings in the parts array for URLs with consecutive or trailing slashes (e.g., /hello//world).
To fix this, after you split the pathname string into an array, you'll need to filter out any empty string elements before sending the response. Once that's addressed, the server should handle all cases correctly.
✨ 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
| // Return instance of http.Server class | ||
| return http.createServer((req, res) => { | ||
| const normalizedUrl = new URL(req.url, `http://${req.headers.host}`); | ||
| const parts = normalizedUrl.pathname.slice(1).split('/'); |
There was a problem hiding this comment.
This line correctly splits the path by /, but it doesn't account for cases with consecutive slashes (e.g., /hello//world) or a trailing slash (e.g., /hello/), which will produce empty strings in the parts array. The requirements state that doubled slashes should be ignored, which implies these empty parts should be removed.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Excellent work on this update! I'm approving your solution. You've successfully addressed the feedback from the previous review by adding the .filter() method to remove empty strings from the URL parts. Your server now correctly handles various URL formats, including those with consecutive or trailing slashes, and meets all the project requirements. Keep up the great work!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Solution