Skip to content

Solution#452

Open
shatskov-artur wants to merge 2 commits intomate-academy:masterfrom
shatskov-artur:develop
Open

Solution#452
shatskov-artur wants to merge 2 commits intomate-academy:masterfrom
shatskov-artur:develop

Conversation

@shatskov-artur
Copy link

Solution

Copy link

@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 setting up the server and handling the query parameters correctly! Your solution is very close, but it requires one adjustment before it can be approved.

The main issue is with how the URL pathname is parsed. The requirement is to ignore doubled slashes, but your current implementation using split('/') produces empty strings in the parts array for URLs with consecutive or trailing slashes (e.g., /hello//world).

To fix this, after you split the pathname string into an array, you'll need to filter out any empty string elements before sending the response. Once that's addressed, the server should handle all cases correctly.


✨ 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

// Return instance of http.Server class
return http.createServer((req, res) => {
const normalizedUrl = new URL(req.url, `http://${req.headers.host}`);
const parts = normalizedUrl.pathname.slice(1).split('/');

Choose a reason for hiding this comment

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

This line correctly splits the path by /, but it doesn't account for cases with consecutive slashes (e.g., /hello//world) or a trailing slash (e.g., /hello/), which will produce empty strings in the parts array. The requirements state that doubled slashes should be ignored, which implies these empty parts should be removed.

Copy link

@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 update! I'm approving your solution. You've successfully addressed the feedback from the previous review by adding the .filter() method to remove empty strings from the URL parts. Your server now correctly handles various URL formats, including those with consecutive or trailing slashes, and meets all the project requirements. 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

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