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

PE-4923: Introduces methods for getting file name and extension #19

Merged
merged 3 commits into from
Nov 20, 2023

Conversation

matibat
Copy link
Contributor

@matibat matibat commented Nov 7, 2023

No description provided.

@matibat matibat self-assigned this Nov 7, 2023
return contentType.substring(contentType.lastIndexOf('/') + 1);
}

String getBasenameWithoutExtension({required String filePath}) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@matibat , can you add the withoutExtension parameter and implement both options: with and without extension?

Copy link
Contributor Author

@matibat matibat Nov 7, 2023

Choose a reason for hiding this comment

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

I'd prefer to introduce a new separate method when needed. 🙏

Comment on lines 117 to 121
test('should return the file type from mimetype', () {
final type = getFileTypeFromMime(contentType: 'application/pdf');

expect(type, 'pdf');
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

@matibat please add more test cases here. Chat GPT can generate for you.

Comment on lines 126 to 130
final basename = getBasenameWithoutExtension(
filePath: '/hola/que/tal/file.pdf',
);

expect(basename, 'file');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment as before. Some test cases:

  • filePath: 'file.pdf'
  • filePath: 'file.pdf.txt'
  • filePath: 'file' <- no extension on the file name (is it possible to get using IOFile?)

Copy link
Collaborator

@thiagocarvalhodev thiagocarvalhodev left a comment

Choose a reason for hiding this comment

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

We need more test cases on the unit tests. This comment is optional: https://github.com/ar-io/ardrive_io/pull/19/files#r1385438373

@matibat
Copy link
Contributor Author

matibat commented Nov 7, 2023

Introduced more test cases, @thiagocarvalhodev .

Copy link
Collaborator

@thiagocarvalhodev thiagocarvalhodev left a comment

Choose a reason for hiding this comment

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

LGTM

@thiagocarvalhodev thiagocarvalhodev merged commit 8e9ddeb into main Nov 20, 2023
2 checks passed
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