Skip to content

Truncate filename for getting artifact upload url #42

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

patricijabrecko
Copy link
Contributor

Summary

This pull request introduces enhancements to filename handling and updates the library version. The key changes include adding new constants for filename length limits, implementing a truncateFilename helper function, and integrating it into the uploader logic to ensure filenames conform to the defined limits.

  • src/common/constants.ts: Added MAX_DEVREV_FILENAME_LENGTH and MAX_DEVREV_FILENAME_EXTENSION_LENGTH constants to define limits for filename length and extension length.
  • src/common/helpers.ts: Implemented the truncateFilename function to truncate filenames exceeding the maximum length, ensuring compliance with the defined limits.
  • src/uploader/uploader.ts: Integrated truncateFilename into the uploader logic to handle filenames before uploading files to the DevRev platform.

Testing Improvements:

  • src/common/helpers.test.ts: Added unit tests for the truncateFilename function, including cases for filenames within limits, at the limit, and exceeding the limit. Mocked console.warn to prevent test output pollution.
  • src/uploader/uploader.test.ts: Added a console.warn spy to the uploader tests to ensure proper mocking and restoration of warnings during tests.

Version Update:

  • package.json: Updated the library version from 1.5.1 to 1.5.2.

Related Issues

Type of Change

  • Change doesn't affect products or customers
  • Bug fix (non-breaking change which fixes an issue)
  • Non-breaking change (the new functionality and code refactor do not require a migration strategy)
  • Breaking change (fix or feature that will require a migration plan for data or other services)
  • Documentation/comment update
  • Other (please describe):

Testing Procedure

  • Link any snap-in with this library, where you notice the errors of filenames being too big and start a new import.

Checklist

  • I used generative AI to generate this PR
  • I have self-reviewed my code for clarity and correctness
  • I have added or updated comments for complex or non-obvious logic in my code
  • I have updated relevant documentation (e.g., README, code docs)
  • My changes do not introduce new warnings or errors
  • I have added or updated tests to cover new or changed functionality
  • All tests pass locally with my changes applied

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.

1 participant