Skip to content

solution#350

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

solution#350
IvanKovalyoff wants to merge 4 commits intomate-academy:masterfrom
IvanKovalyoff:develop

Conversation

@IvanKovalyoff
Copy link
Copy Markdown

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 building this static file server! The implementation is solid, especially the security measures to prevent path traversal. I am requesting one change to fully meet the project requirements.

Currently, a request to the /file endpoint returns a hint message. The task requires that both /file and /file/ serve the public/index.html file. Please adjust your logic to ensure that a request to /file is handled the same way as a request to /file/. Once that's updated, this will be ready for approval!


✨ 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 +22 to +27
if (pathname === '/file') {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hint: load files using /file/<path-to-file>');

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 returns a hint message instead. This logic should be adjusted to treat /file the same as a request to /file/.

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 progress on your static file server! The security measures and general file-serving logic are well-implemented.

However, this requires a change because a key requirement is still not met. A request to the /file endpoint currently returns a hint message instead of serving public/index.html. The issue is in the block that checks if (pathname === '/file'), which sends a response and then uses return, stopping the request from being processed further.

To fix this, you should modify the pathname inside that block to be /file/ and then let the execution continue so that it's handled by the existing file-serving logic. Once that's adjusted, your solution will be complete!


✨ 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 +22 to +28
if (pathname === '/file') {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hint: load files using /file/<path-to-file>');
pathname = '/file/';

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.

This block correctly identifies a request to /file, but it sends a hint and stops the request with return. According to the requirements, a request to /file should serve public/index.html, the same way /file/ does. Consider removing the response here and instead modifying the pathname so that it's treated like a request for /file/ by the logic that follows.

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 file server, especially with the security measures to prevent directory traversal! I'm approving this submission as an educational override to help you move forward, but please note there are a couple of routing requirements that still need attention.

Currently, a request to /file doesn't serve public/index.html as required. You can fix this by adjusting your logic to handle /file the same way you handle /file/. Also, any path that doesn't start with /file/ (like /) should return the hint message, not a 'Bad Request' error.

You're very close to a complete solution. Keep up the great work!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

Comment on lines +22 to +27
if (pathname === '/file') {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hint: load files using /file/<path-to-file>');

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.

This logic doesn't meet the requirement that a request to /file should serve public/index.html. Currently, it returns a hint message and stops execution, which was also pointed out in the previous review. This block needs to be adjusted so that /file requests are handled the same way as /file/ requests, eventually serving index.html.

Comment on lines +30 to +35
if (!pathname.startsWith('/file/')) {
res.writeHead(400, { 'Content-Type': 'text/plain' });
res.end('Bad Request');

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, if a pathname does not start with /file/, the server should return a hint message. This implementation incorrectly returns a 'Bad Request' with a 400 status code.

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