Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I'm requesting a few changes to your server logic. You've done a great job implementing the core file-serving functionality and including strong security checks to prevent directory traversal!
However, there are two specific cases where the server's response doesn't match the requirements:
- Paths not starting with
/file/: Any request to a path that doesn't start with/file/(like/or/about) should return a helpful hint message, but it's currently sending a400 Bad Request. - The
/fileendpoint: A request to/fileshould servepublic/index.html, but it's returning a hint message instead. This path should be treated the same as/file/.
Please adjust your path handling logic in src/createServer.js to correctly manage these two scenarios. Keep up the great work!
✨ 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
| if (!pathname.startsWith('/file')) { | ||
| return sendTextResponse(400, 'Bad Request'); | ||
| } |
There was a problem hiding this comment.
According to the requirements, if a pathname does not start with /file/, you should return a hint message. This check for paths not starting with /file (like / or /about) should return a hint instead of a 400 Bad Request error.
src/createServer.js
Outdated
| if (pathname === '/file') { | ||
| return sendTextResponse(200, 'To get a file use /file/path/to/file'); | ||
| } |
There was a problem hiding this comment.
The requirements state that a request to /file should serve public/index.html. Your current implementation returns a hint message instead of the file. This block of code prevents the request from being processed further down, where it would be correctly resolved to index.html.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Excellent work on this iteration! You've successfully addressed all the feedback from the previous review, and the server now behaves exactly as required. The path handling logic is robust, correctly managing edge cases like /file and providing the hint message for other paths. All requirements have been met, so I am approving your solution. Nicely done!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.