Skip to content

solution#353

Open
Nazarii-Lesniak wants to merge 2 commits intomate-academy:masterfrom
Nazarii-Lesniak:develop
Open

solution#353
Nazarii-Lesniak wants to merge 2 commits intomate-academy:masterfrom
Nazarii-Lesniak:develop

Conversation

@Nazarii-Lesniak
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

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:

  1. 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 a 400 Bad Request.
  2. The /file endpoint: A request to /file should serve public/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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment on lines +23 to +25
if (!pathname.startsWith('/file')) {
return sendTextResponse(400, 'Bad Request');
}
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 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.

Comment on lines +27 to +29
if (pathname === '/file') {
return sendTextResponse(200, 'To get a file use /file/path/to/file');
}
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 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.

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

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! ✨

Footnotes

  1. Rate AI review example

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