mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-07 17:10:29 +00:00
feat: add FFmpeg WASM runtime (#1512)
This commit is contained in:
31 files changed
+2305
-24
No files matched your search
@@ -299,8 +299,9 @@ TaskAssetType _assetType(String name, {required bool isFolder, required api_task
|
||||
}
|
||||
|
||||
String _fileExtension(String name) {
|
||||
final pathWithoutQuery = name.split(RegExp(r'[?#]')).first;
|
||||
final extension = path.extension(pathWithoutQuery).replaceFirst('.', '').toLowerCase();
|
||||
final uri = Uri.tryParse(name);
|
||||
final filePath = uri != null && uri.hasScheme && uri.hasAuthority ? uri.path : name;
|
||||
final extension = path.extension(filePath).replaceFirst('.', '').toLowerCase();
|
||||
return extension.length <= 10 ? extension : '';
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:gopeed/core/icons/gopeed_icons.dart';
|
||||
import 'package:gopeed/features/tasks/domain/task_record.dart';
|
||||
|
||||
void main() {
|
||||
test('file names preserve hash and question mark characters for type detection', () {
|
||||
expect(
|
||||
taskFileTypeIcon('Slow English Podcast #2 _ Eating, Talking, and Learning Natural English.mp4'),
|
||||
GopeedIcons.fileVideo,
|
||||
);
|
||||
expect(taskFileTypeIcon('What is this? #2.MP4'), GopeedIcons.fileVideo);
|
||||
expect(taskFileTypeIcon('Episode #2.mp3'), GopeedIcons.fileAudio);
|
||||
});
|
||||
|
||||
test('URL fallback ignores query and fragment when detecting file type', () {
|
||||
expect(taskFileTypeIcon('https://example.com/video.mp4?token=abc#part'), GopeedIcons.fileVideo);
|
||||
expect(taskFileTypeIcon('https://example.com/download?name=video.mp4'), GopeedIcons.file);
|
||||
expect(taskFileTypeIcon('Playlist #2.mp4', isFolder: true), GopeedIcons.folder);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user