Skip to content

Add solution#358

Open
ProKesha wants to merge 4 commits intomate-academy:masterfrom
ProKesha:develop
Open

Add solution#358
ProKesha wants to merge 4 commits intomate-academy:masterfrom
ProKesha:develop

Conversation

@ProKesha
Copy link
Copy Markdown

@ProKesha ProKesha commented Mar 27, 2026

No description provided.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. 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 a 400 Forbidden error for these paths.
  2. Incorrect handling of the /file route: According to the requirements, a request to /file should serve the public/index.html file, 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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment on lines +38 to +46
if (pathname === FILE_PREFIX) {
sendText(
response,
200,
'Use /file/<path> to load files from the public folder',
);

return;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the task description, a request to /file should return public/index.html. This implementation incorrectly returns a hint message instead.

Comment on lines +48 to +51
if (!pathname.startsWith(`${FILE_PREFIX}/`)) {
sendText(response, 400, 'Access outside public folder is forbidden');

return;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. A request to the /file path should serve the public/index.html file, similar to how /file/ is handled. Currently, it's returning a text hint instead.
  2. 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 a 400 Forbidden error.

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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment on lines +38 to +45
if (pathname === FILE_PREFIX) {
sendText(
response,
200,
'Use /file/<path> to load files from the public folder',
);

return;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +48 to +51
if (!pathname.startsWith(`${FILE_PREFIX}/`)) {
sendText(response, 400, 'Access outside public folder is forbidden');

return;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. A request to the /file path should serve public/index.html, but it currently returns a hint.
  2. Requests to any path that doesn't start with /file/ (like / or /test) should return a helpful hint message instead of the current 400 Forbidden error.

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

  1. Rate AI review example

return;
}

if (pathname === FILE_PREFIX) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}/`)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants