diff --git a/android/settings.gradle.kts b/android/settings.gradle.kts index 34c3a2b7..ca7fe065 100644 --- a/android/settings.gradle.kts +++ b/android/settings.gradle.kts @@ -20,7 +20,7 @@ pluginManagement { plugins { id("dev.flutter.flutter-plugin-loader") version "1.0.0" id("com.android.application") version "8.11.1" apply false - id("org.jetbrains.kotlin.android") version "2.1.0" apply false + id("org.jetbrains.kotlin.android") version "2.2.20" apply false } include(":app") diff --git a/lib/helpers/message_url_image_helper.dart b/lib/helpers/message_url_image_helper.dart index 17a46923..d917af6d 100644 --- a/lib/helpers/message_url_image_helper.dart +++ b/lib/helpers/message_url_image_helper.dart @@ -27,7 +27,7 @@ class MessageUrlImageHelper { ); static final RegExp _ipfsCidPattern = RegExp( - r'''ipfs://([^\s<>'"`]+)''', + r'''ipfs:(?://)?([^\s<>'"`]+)''', caseSensitive: false, ); diff --git a/test/helpers/message_url_image_helper_test.dart b/test/helpers/message_url_image_helper_test.dart index 17d43678..ecb2712b 100644 --- a/test/helpers/message_url_image_helper_test.dart +++ b/test/helpers/message_url_image_helper_test.dart @@ -45,6 +45,17 @@ void main() { ); }); + test('parses direct ipfs cid urls without double slashes', () async { + final attachment = await MessageUrlImageHelper.parse( + 'my picture: ipfs:bafybeibq75ws6nwk6wi473dch42wwy6woyj4dwdfy7nfz3buqx2caieoly text', + ); + + expect( + attachment, + 'https://ipfs.io/ipfs/bafybeibq75ws6nwk6wi473dch42wwy6woyj4dwdfy7nfz3buqx2caieoly', + ); + }); + test('parses http image urls', () async { final attachment = await MessageUrlImageHelper.parse( 'see this image https://example.com/picture.png?size=large additional text',