Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #129

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Develop #129

wants to merge 5 commits into from

Conversation

mrsvolodya
Copy link

@mrsvolodya mrsvolodya commented Nov 2, 2024

Hi, I sent scrins, can you check where was mistake with Content-Encoding? AI suggested me use gzip , but after this test won't pass...
image

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.


Thank you for your hard work on this project! 😊 While your implementation is mostly solid and meets the task requirements, there are a few critical issues that need to be addressed before we can approve the pull request:

  1. File Existence Check: After checking if a file exists and sending a 404 response, the code should return immediately to prevent further execution. This is crucial to avoid any unintended behavior or errors.

  2. File Handling Logic: There is a potential issue with the assignment of filePath and fileName. If files.file is not an array, the code incorrectly assigns the entire file object. Ensure you access the filepath and originalFilename properties directly in the else case to avoid this mistake.

  3. Content Encoding Headers: The content encoding headers are incorrect. For gzip, the header should be 'gzip', and for deflate, it should be 'deflate'. Please update these headers to use the correct values.

Once these issues are resolved, your code will be in great shape! Keep up the great work, and don't hesitate to reach out if you need any help. 🚀

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

🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review button in the Reviewers tab.

Comment on lines 94 to 99
res.setHeader('Content-Encoding', 'gz');
extension = 'gzip';
break;
case 'deflate':
compressionData = createDeflate();
res.setHeader('Content-Encoding', '.dfl');

Choose a reason for hiding this comment

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

The content encoding headers are incorrect. For gzip, the correct header should be 'gzip' instead of 'gz'. Similarly, for deflate, the correct header should be 'deflate' instead of '.dfl'. Please update these headers to reflect the correct content encoding values.

Copy link
Author

Choose a reason for hiding this comment

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

For gzip, I should use 'gz' because it doesn't pass the test.!!!! Similarly, for deflate, I should use '.dfl'

Comment on lines 71 to 75
? files.file[0].filepath
: files.file;
const fileName = Array.isArray(files.file)
? files.file[0].originalFilename
: files.file;

Choose a reason for hiding this comment

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

There is a potential issue with the way filePath and fileName are assigned. If files.file is not an array, the code assigns the entire file object to filePath and fileName, which is likely incorrect. You should access the filepath and originalFilename properties directly in the else case.

mrsvolodya added 2 commits November 2, 2024 22:22
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.

Thank you for your submission! Your code meets the task requirements and constraints, and you've done a great job implementing the server and HTML form. However, there are a few critical issues that need to be addressed to ensure the functionality of your code:

  1. Content Encoding Headers:

    • The content encoding header for Brotli should be 'br' instead of '.br'.
    • The content encoding header for deflate should be 'deflate' instead of '.dfl'.
    • The content encoding header for gzip should be 'gzip' instead of 'gz'.
      These are critical issues as they may cause clients to misinterpret the encoding.
  2. Validation of Uploaded Files and Compression Types:

    • Ensure that 'files.file' is correctly parsed and validated. If 'files.file' is not an array, this logic might fail. Consider adding additional validation to handle different data structures.
    • Similarly, ensure that 'fields.compressionType' is correctly parsed and validated. If 'fields.compressionType' is not an array, this logic might fail.

Despite these issues, the decision is to APPROVE your pull request to help you move forward with your learning. Please review the comments and make the necessary improvements to your code. Addressing these issues will enhance the robustness and correctness of your implementation. Keep up the good work, and continue learning from these experiences! 🚀

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

switch (compressionType) {
case 'gzip':
compressionData = createGzip();
res.setHeader('Content-Encoding', 'gz');

Choose a reason for hiding this comment

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

The content encoding header for gzip should be 'gzip' instead of 'gz'. This is a critical issue as it may cause clients to misinterpret the encoding.

Copy link
Author

Choose a reason for hiding this comment

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

image
image

break;
case 'deflate':
compressionData = createDeflate();
res.setHeader('Content-Encoding', '.dfl');

Choose a reason for hiding this comment

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

The content encoding header for deflate should be 'deflate' instead of '.dfl'. This is a critical issue as it may cause clients to misinterpret the encoding.

break;
case 'br':
compressionData = createBrotliCompress();
res.setHeader('Content-Encoding', '.br');

Choose a reason for hiding this comment

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

The content encoding header for Brotli should be 'br' instead of '.br'. This is a critical issue as it may cause clients to misinterpret the encoding.

Comment on lines 66 to 67
const compressionType =
Array.isArray(fields.compressionType) && fields.compressionType[0];

Choose a reason for hiding this comment

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

Ensure that 'fields.compressionType' is correctly parsed and validated. If 'fields.compressionType' is not an array, this logic might fail. Consider adding additional validation to handle different data structures.

const compressionType =
Array.isArray(fields.compressionType) && fields.compressionType[0];

const filePath = Array.isArray(files.file) && files.file[0].filepath;

Choose a reason for hiding this comment

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

Ensure that 'files.file' is correctly parsed and validated. If 'files.file' is not an array, this logic might fail. Consider adding additional validation to handle different data structures.

Comment on lines 71 to 72
const fileName =
Array.isArray(files.file) && files.file[0].originalFilename;

Choose a reason for hiding this comment

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

Ensure that 'files.file' is correctly parsed and validated. If 'files.file' is not an array, this logic might fail. Consider adding additional validation to handle different data structures.

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.

3 participants