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

Disregard query string when checking if path points to image/video #121

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/files.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ bool isLocalFilePath(String path) {
}

bool isVideo(String path) =>
videoFormats.contains(extension(path).toLowerCase());
videoFormats.contains(fromUri(extension(path)).toLowerCase());

bool isImage(String path) =>
imageFormats.contains(extension(path).toLowerCase());
imageFormats.contains(fromUri(extension(path)).toLowerCase());
15 changes: 15 additions & 0 deletions test/gallery_saver_test.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:gallery_saver/gallery_saver.dart';

import '../lib/files.dart';

void main() {
TestWidgetsFlutterBinding.ensureInitialized();

const MethodChannel channel = MethodChannel('gallery_saver');

setUp(() {
Expand All @@ -28,4 +33,14 @@ void main() {
test('save video', () async {
expect(await GallerySaver.saveVideo('/storage/emulated/video.mov'), false);
});

test('disregard query string for image', () {
const String url = "https://placeholder.com/400x400.jpg?remove=true";
expect(isImage(url), true);
});

test('disregard query string for video', () {
const String url = "https://placeholder.com/400x400.mov?remove=true";
expect(isVideo(url), true);
});
}