diff --git a/lib/app_sources/apkcombo.dart b/lib/app_sources/apkcombo.dart index 3a1ae49..b63afa6 100644 --- a/lib/app_sources/apkcombo.dart +++ b/lib/app_sources/apkcombo.dart @@ -10,7 +10,7 @@ class APKCombo extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { RegExp standardUrlRegEx = RegExp( '^https?://(www\\.)?${getSourceRegex(hosts)}/+[^/]+/+[^/]+', caseSensitive: false); diff --git a/lib/app_sources/apkmirror.dart b/lib/app_sources/apkmirror.dart index 236a300..1b3a67b 100644 --- a/lib/app_sources/apkmirror.dart +++ b/lib/app_sources/apkmirror.dart @@ -32,7 +32,7 @@ class APKMirror extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { RegExp standardUrlRegEx = RegExp( '^https?://(www\\.)?${getSourceRegex(hosts)}/apk/[^/]+/[^/]+', caseSensitive: false); diff --git a/lib/app_sources/apkpure.dart b/lib/app_sources/apkpure.dart index fe5e549..82fdf23 100644 --- a/lib/app_sources/apkpure.dart +++ b/lib/app_sources/apkpure.dart @@ -29,7 +29,7 @@ class APKPure extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { RegExp standardUrlRegExB = RegExp( '^https?://m.${getSourceRegex(hosts)}(/+[^/]{2})?/+[^/]+/+[^/]+', caseSensitive: false); diff --git a/lib/app_sources/aptoide.dart b/lib/app_sources/aptoide.dart index 9daf57b..b545d8a 100644 --- a/lib/app_sources/aptoide.dart +++ b/lib/app_sources/aptoide.dart @@ -14,7 +14,7 @@ class Aptoide extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { RegExp standardUrlRegEx = RegExp( '^https?://([^\\.]+\\.){2,}${getSourceRegex(hosts)}', caseSensitive: false); diff --git a/lib/app_sources/codeberg.dart b/lib/app_sources/codeberg.dart index 6354ea4..e2899c3 100644 --- a/lib/app_sources/codeberg.dart +++ b/lib/app_sources/codeberg.dart @@ -16,7 +16,7 @@ class Codeberg extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { RegExp standardUrlRegEx = RegExp( '^https?://(www\\.)?${getSourceRegex(hosts)}/[^/]+/[^/]+', caseSensitive: false); diff --git a/lib/app_sources/directAPKLink.dart b/lib/app_sources/directAPKLink.dart index f80a711..1addc13 100644 --- a/lib/app_sources/directAPKLink.dart +++ b/lib/app_sources/directAPKLink.dart @@ -1,12 +1,12 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:obtainium/app_sources/html.dart'; +import 'package:obtainium/custom_errors.dart'; import 'package:obtainium/providers/source_provider.dart'; class DirectAPKLink extends AppSource { HTML html = HTML(); DirectAPKLink() { - neverAutoSelect = true; name = tr('directAPKLink'); additionalSourceAppSpecificSettingFormItems = html .additionalSourceAppSpecificSettingFormItems @@ -24,6 +24,20 @@ class DirectAPKLink extends AppSource { ]; } + @override + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { + print('AAA'); + if (!forSelection) { + return url; + } + RegExp standardUrlRegExA = RegExp('.+\\.apk\$', caseSensitive: false); + var match = standardUrlRegExA.firstMatch(url); + if (match == null) { + throw InvalidURLError(name); + } + return match.group(0)!; + } + @override Future?> getRequestHeaders( Map additionalSettings, diff --git a/lib/app_sources/fdroid.dart b/lib/app_sources/fdroid.dart index ac08801..22d3791 100644 --- a/lib/app_sources/fdroid.dart +++ b/lib/app_sources/fdroid.dart @@ -38,7 +38,7 @@ class FDroid extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { RegExp standardUrlRegExB = RegExp( '^https?://(www\\.)?${getSourceRegex(hosts)}/+[^/]+/+packages/+[^/]+', caseSensitive: false); diff --git a/lib/app_sources/fdroidrepo.dart b/lib/app_sources/fdroidrepo.dart index f4afe08..c8cc536 100644 --- a/lib/app_sources/fdroidrepo.dart +++ b/lib/app_sources/fdroidrepo.dart @@ -43,7 +43,7 @@ class FDroidRepo extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { var standardUri = Uri.parse(url); var pathSegments = standardUri.pathSegments; if (pathSegments.isNotEmpty && pathSegments.last == 'index.xml') { diff --git a/lib/app_sources/github.dart b/lib/app_sources/github.dart index 2f0fb42..a0af39e 100644 --- a/lib/app_sources/github.dart +++ b/lib/app_sources/github.dart @@ -154,7 +154,7 @@ class GitHub extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { RegExp standardUrlRegEx = RegExp( '^https?://(www\\.)?${getSourceRegex(hosts)}/[^/]+/[^/]+', caseSensitive: false); diff --git a/lib/app_sources/gitlab.dart b/lib/app_sources/gitlab.dart index 395c596..e8404a4 100644 --- a/lib/app_sources/gitlab.dart +++ b/lib/app_sources/gitlab.dart @@ -52,7 +52,7 @@ class GitLab extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { RegExp standardUrlRegEx = RegExp( '^https?://(www\\.)?${getSourceRegex(hosts)}/[^/]+/[^/]+', caseSensitive: false); diff --git a/lib/app_sources/html.dart b/lib/app_sources/html.dart index 46f5a65..d3244d8 100644 --- a/lib/app_sources/html.dart +++ b/lib/app_sources/html.dart @@ -288,7 +288,7 @@ class HTML extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { return url; } diff --git a/lib/app_sources/huaweiappgallery.dart b/lib/app_sources/huaweiappgallery.dart index 0f2be00..0716597 100644 --- a/lib/app_sources/huaweiappgallery.dart +++ b/lib/app_sources/huaweiappgallery.dart @@ -12,7 +12,7 @@ class HuaweiAppGallery extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { RegExp standardUrlRegEx = RegExp( '^https?://(www\\.)?${getSourceRegex(hosts)}(/#)?/(app|appdl)/[^/]+', caseSensitive: false); diff --git a/lib/app_sources/izzyondroid.dart b/lib/app_sources/izzyondroid.dart index d49071e..2960c6e 100644 --- a/lib/app_sources/izzyondroid.dart +++ b/lib/app_sources/izzyondroid.dart @@ -14,7 +14,7 @@ class IzzyOnDroid extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { RegExp standardUrlRegExA = RegExp( '^https?://android.${getSourceRegex(hosts)}/repo/apk/[^/]+', caseSensitive: false); diff --git a/lib/app_sources/mullvad.dart b/lib/app_sources/mullvad.dart index 3b0439d..3980930 100644 --- a/lib/app_sources/mullvad.dart +++ b/lib/app_sources/mullvad.dart @@ -10,7 +10,7 @@ class Mullvad extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { RegExp standardUrlRegEx = RegExp( '^https?://(www\\.)?${getSourceRegex(hosts)}', caseSensitive: false); diff --git a/lib/app_sources/neutroncode.dart b/lib/app_sources/neutroncode.dart index 0429718..cc3d501 100644 --- a/lib/app_sources/neutroncode.dart +++ b/lib/app_sources/neutroncode.dart @@ -10,7 +10,7 @@ class NeutronCode extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { RegExp standardUrlRegEx = RegExp( '^https?://(www\\.)?${getSourceRegex(hosts)}/downloads/file/[^/]+', caseSensitive: false); diff --git a/lib/app_sources/signal.dart b/lib/app_sources/signal.dart index 8e91939..6bbaddb 100644 --- a/lib/app_sources/signal.dart +++ b/lib/app_sources/signal.dart @@ -9,7 +9,7 @@ class Signal extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { return 'https://${hosts[0]}'; } diff --git a/lib/app_sources/sourceforge.dart b/lib/app_sources/sourceforge.dart index caaeea8..50fc76a 100644 --- a/lib/app_sources/sourceforge.dart +++ b/lib/app_sources/sourceforge.dart @@ -9,7 +9,7 @@ class SourceForge extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { var sourceRegex = getSourceRegex(hosts); RegExp standardUrlRegExC = RegExp('^https?://(www\\.)?$sourceRegex/p/.+', caseSensitive: false); diff --git a/lib/app_sources/sourcehut.dart b/lib/app_sources/sourcehut.dart index e28294c..51e98b5 100644 --- a/lib/app_sources/sourcehut.dart +++ b/lib/app_sources/sourcehut.dart @@ -20,7 +20,7 @@ class SourceHut extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { RegExp standardUrlRegEx = RegExp( '^https?://(www\\.)?${getSourceRegex(hosts)}/[^/]+/[^/]+', caseSensitive: false); diff --git a/lib/app_sources/steammobile.dart b/lib/app_sources/steammobile.dart index cbb28ef..8e6c11e 100644 --- a/lib/app_sources/steammobile.dart +++ b/lib/app_sources/steammobile.dart @@ -20,7 +20,7 @@ class SteamMobile extends AppSource { final apks = {'steam': tr('steamMobile'), 'steam-chat-app': tr('steamChat')}; @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { return 'https://${hosts[0]}'; } diff --git a/lib/app_sources/telegramapp.dart b/lib/app_sources/telegramapp.dart index 651d00f..7c6372b 100644 --- a/lib/app_sources/telegramapp.dart +++ b/lib/app_sources/telegramapp.dart @@ -11,7 +11,7 @@ class TelegramApp extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { return 'https://${hosts[0]}'; } diff --git a/lib/app_sources/uptodown.dart b/lib/app_sources/uptodown.dart index 30c86ce..e59998c 100644 --- a/lib/app_sources/uptodown.dart +++ b/lib/app_sources/uptodown.dart @@ -14,7 +14,7 @@ class Uptodown extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { RegExp standardUrlRegEx = RegExp( '^https?://([^\\.]+\\.){2,}${getSourceRegex(hosts)}', caseSensitive: false); diff --git a/lib/app_sources/vlc.dart b/lib/app_sources/vlc.dart index 7d16870..4ee0f50 100644 --- a/lib/app_sources/vlc.dart +++ b/lib/app_sources/vlc.dart @@ -21,7 +21,7 @@ class VLC extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { return 'https://${hosts[0]}'; } diff --git a/lib/app_sources/whatsapp.dart b/lib/app_sources/whatsapp.dart index 94b26d1..b6e88d2 100644 --- a/lib/app_sources/whatsapp.dart +++ b/lib/app_sources/whatsapp.dart @@ -10,7 +10,7 @@ class WhatsApp extends AppSource { } @override - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { return 'https://${hosts[0]}'; } diff --git a/lib/providers/source_provider.dart b/lib/providers/source_provider.dart index 8b1c41e..d60e19f 100644 --- a/lib/providers/source_provider.dart +++ b/lib/providers/source_provider.dart @@ -472,7 +472,7 @@ abstract class AppSource { // } - String sourceSpecificStandardizeURL(String url) { + String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) { throw NotImplementedError(); } @@ -809,7 +809,7 @@ class SourceProvider { for (var s in sources.where( (element) => element.hosts.isEmpty && !element.neverAutoSelect)) { try { - s.sourceSpecificStandardizeURL(url); + s.sourceSpecificStandardizeURL(url, forSelection: true); source = s; break; } catch (e) {