Skip to content

Commit 5cc6aa4

Browse files
committed
Add assert
1 parent f99a0be commit 5cc6aa4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/src/utils/helpers.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ Map merge(Map? obj, Map? defaults) {
1717
}
1818

1919
String fileExtensionFromPath(String path) {
20-
final splitter = path.split('.');
21-
return splitter.length > 1 ? splitter.last : "";
20+
final parts = path.split('.');
21+
22+
assert(parts.length > 1 && parts.last.isNotEmpty,
23+
'Invalid file path format: $path. Path should contain a valid extension.');
24+
25+
return parts.last;
2226
}
2327

2428
/// Helper function to format bytes into a human-readable string (e.g., KB, MB, GB).

0 commit comments

Comments
 (0)