Truncate filename for getting artifact upload url #42
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
: AddedMAX_DEVREV_FILENAME_LENGTH
andMAX_DEVREV_FILENAME_EXTENSION_LENGTH
constants to define limits for filename length and extension length.src/common/helpers.ts
: Implemented thetruncateFilename
function to truncate filenames exceeding the maximum length, ensuring compliance with the defined limits.src/uploader/uploader.ts
: IntegratedtruncateFilename
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 thetruncateFilename
function, including cases for filenames within limits, at the limit, and exceeding the limit. Mockedconsole.warn
to prevent test output pollution.src/uploader/uploader.test.ts
: Added aconsole.warn
spy to the uploader tests to ensure proper mocking and restoration of warnings during tests.Version Update:
package.json
: Updated the library version from1.5.1
to1.5.2
.Related Issues
Type of Change
Testing Procedure
Checklist