From fe510753d279e2078d9f5c87b0456c04cff09b93 Mon Sep 17 00:00:00 2001 From: Mark Szente Date: Sat, 15 May 2021 19:52:37 +0200 Subject: [PATCH 1/3] Fix tests --- test/gallery_saver_test.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/gallery_saver_test.dart b/test/gallery_saver_test.dart index 47456b1..896506b 100644 --- a/test/gallery_saver_test.dart +++ b/test/gallery_saver_test.dart @@ -1,8 +1,11 @@ import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:gallery_saver/gallery_saver.dart'; void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + const MethodChannel channel = MethodChannel('gallery_saver'); setUp(() { From 04ddef62d50d6cbae567b2d20b01a38c2b7951c6 Mon Sep 17 00:00:00 2001 From: Mark Szente Date: Sat, 15 May 2021 19:53:53 +0200 Subject: [PATCH 2/3] Add tests for query string disregard --- test/gallery_saver_test.dart | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/gallery_saver_test.dart b/test/gallery_saver_test.dart index 896506b..a993318 100644 --- a/test/gallery_saver_test.dart +++ b/test/gallery_saver_test.dart @@ -3,6 +3,8 @@ 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(); @@ -31,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); + }); } From 2310a8bc37b67069eaa719eb303b7172958ef586 Mon Sep 17 00:00:00 2001 From: Mark Szente Date: Sat, 15 May 2021 19:54:50 +0200 Subject: [PATCH 3/3] Disregard query string when checking if url is a valid image/video --- lib/files.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/files.dart b/lib/files.dart index debc453..9eb6994 100644 --- a/lib/files.dart +++ b/lib/files.dart @@ -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());