Auto-select direct APK source for URLs ending in '.apk' (#1820)

This commit is contained in:
Imran Remtulla
2024-09-08 02:51:11 -04:00
parent e019c8027b
commit 0e46a83843
24 changed files with 39 additions and 25 deletions

View File

@ -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<Map<String, String>?> getRequestHeaders(
Map<String, dynamic> additionalSettings,