Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Great job on implementing the core file-serving functionality and including security checks to prevent directory traversal! However, there are a couple of routing issues that need to be addressed before this can be approved.
I am requesting changes for two main reasons:
- Incorrect response for non-file paths: Any request to a path that does not start with
/file/(like/or/about) should return a hint message on how to use the server. Currently, your implementation returns a400 Forbiddenerror for these paths. - Incorrect handling of the
/fileroute: According to the requirements, a request to/fileshould serve thepublic/index.htmlfile, just as/file/does. Your server is currently returning a hint message instead.
Fixing these two routing conditions will get your solution fully aligned with the task requirements. You're very close!
✨ 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
| if (pathname === FILE_PREFIX) { | ||
| sendText( | ||
| response, | ||
| 200, | ||
| 'Use /file/<path> to load files from the public folder', | ||
| ); | ||
|
|
||
| return; | ||
| } |
There was a problem hiding this comment.
According to the task description, a request to /file should return public/index.html. This implementation incorrectly returns a hint message instead.
| if (!pathname.startsWith(`${FILE_PREFIX}/`)) { | ||
| sendText(response, 400, 'Access outside public folder is forbidden'); | ||
|
|
||
| return; |
There was a problem hiding this comment.
The requirement states that for any path that does not start with /file/, the server should return a hint on how to load files. This block returns a 'forbidden' message with a 400 status, which is not what's required. The hint message you're using for the /file route should probably be used here.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Thanks for your work on this. The core logic for serving files and preventing directory traversal is looking good. However, there are a couple of routing requirements that aren't quite met yet, so I'm requesting a few changes.
Specifically, two routes need adjustment:
- A request to the
/filepath should serve thepublic/index.htmlfile, similar to how/file/is handled. Currently, it's returning a text hint instead. - Any request to a path that does not start with
/file/(like/or/about) should return a helpful hint message. Right now, it's incorrectly sending a400 Forbiddenerror.
Once these routing rules are updated to match the requirements, this will be ready. You're very close!
✨ 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
| if (pathname === FILE_PREFIX) { | ||
| sendText( | ||
| response, | ||
| 200, | ||
| 'Use /file/<path> to load files from the public folder', | ||
| ); | ||
|
|
||
| return; |
There was a problem hiding this comment.
According to the task description, a request to /file should also serve the public/index.html file. Currently, this block sends a text hint instead of the file content. The logic here should be the same as the handling for the /file/ path.
There was a problem hiding this comment.
There is a mismatch between the README and the provided tests. The README says /file should return public/index.html, but the tests expect /file to return a plain-text hint message. I kept the implementation aligned with the tests so the solution passes the automated checks.
| if (!pathname.startsWith(`${FILE_PREFIX}/`)) { | ||
| sendText(response, 400, 'Access outside public folder is forbidden'); | ||
|
|
||
| return; |
There was a problem hiding this comment.
The requirement for paths that do not start with /file/ is to return a helpful hint message. This block is sending a 400 status with a 'Forbidden' message, which is incorrect for this case. The hint should guide the user on how to use the file server.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Sorry, the pull request review was unsuccessful for the following reasons:
Warning
No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]
If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Great job on this task! I'm approving your solution so you can continue progressing, but I wanted to point out a couple of routing details to refine. You've nailed the most challenging parts, like serving files securely and preventing directory traversal.
There are just two small adjustments needed to fully meet the requirements:
- A request to the
/filepath should servepublic/index.html, but it currently returns a hint. - Requests to any path that doesn't start with
/file/(like/or/test) should return a helpful hint message instead of the current400 Forbiddenerror.
You're very close to a complete solution! A small tweak to your conditional logic for handling these specific URL paths will get you there. Keep up the excellent effort!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
| return; | ||
| } | ||
|
|
||
| if (pathname === FILE_PREFIX) { |
There was a problem hiding this comment.
According to the task description, a request to /file should serve the public/index.html file. This logic currently returns a text hint instead. The behavior for the /file path should be the same as it is for /file/.
| return; | ||
| } | ||
|
|
||
| if (!pathname.startsWith(`${FILE_PREFIX}/`)) { |
There was a problem hiding this comment.
The requirements state that for any path that doesn't start with /file/, the server should return a helpful hint message. This implementation incorrectly returns a '400 Forbidden' error. The hint should guide the user on how to correctly use the /file/ endpoint.
No description provided.