Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
REQUEST_CHANGES
Thank you for your submission! Your server implementation is clear and handles most requirements well, especially with parsing query parameters and structuring the JSON response. However, there is a critical blocker that needs to be addressed before approval:
- Path Segments Handling: The
partsarray in your JSON response may include empty strings when the path has leading, trailing, or consecutive slashes. According to the requirements, empty segments must be ignored. For example,/hello//world/should result inparts: ['hello', 'world'], and/or////should result inparts: [].
What to fix:
- After splitting the pathname by
/, filter out empty strings:This will ensure only non-empty path segments are included in thepathname.split('/').filter(Boolean)
partsarray, matching the specification.
Once you make this adjustment, your code should fully meet the requirements. Great job on the rest of the implementation—you're very close! Let me know if you have any questions about this change.
✨ 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
| const normalizedUrl = new URL(preparedUrl, BASE_URL); | ||
|
|
||
| const pathname = normalizedUrl.pathname.slice(1); | ||
| const pathnameArray = pathname.split('/'); |
There was a problem hiding this comment.
The code splits the pathname using pathname.split('/'), but does not filter out empty strings. According to the requirements, empty strings resulting from leading, trailing, or consecutive slashes must be ignored. You should filter the array to remove empty strings, e.g., pathname.split('/').filter(Boolean).
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
All core requirements are fully met. Your HTTP server implementation correctly parses the URL path into non-empty segments (ignoring doubled or more slashes), extracts query parameters into an object, and responds with the expected JSON format. Edge cases such as empty paths and missing query parameters are handled robustly. The code is clean, concise, and directly addresses the task's needs. Great job! You can proceed to the next step.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.