mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-18 20:49:30 +02:00
Multi-host support + add '.net' host to APKPure source (#1250)
This commit is contained in:
@@ -14,7 +14,7 @@ import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:shared_storage/shared_storage.dart' as saf;
|
||||
|
||||
String obtainiumTempId = 'imranr98_obtainium_${GitHub().host}';
|
||||
String obtainiumTempId = 'imranr98_obtainium_${GitHub().hosts[0]}';
|
||||
String obtainiumId = 'dev.imranr.obtainium';
|
||||
|
||||
enum InstallMethodSettings { normal, shizuku, root }
|
||||
|
@@ -366,8 +366,12 @@ List<MapEntry<String, String>> getApkUrlsFromUrls(List<String> urls) =>
|
||||
return MapEntry(apkSegs.isNotEmpty ? apkSegs.last : segments.last, e);
|
||||
}).toList();
|
||||
|
||||
getSourceRegex(List<String> hosts) {
|
||||
return '(${hosts.join('|').replaceAll('.', '\\.')})';
|
||||
}
|
||||
|
||||
abstract class AppSource {
|
||||
String? host;
|
||||
List<String> hosts = [];
|
||||
bool hostChanged = false;
|
||||
late String name;
|
||||
bool enforceTrackOnly = false;
|
||||
@@ -697,14 +701,14 @@ class SourceProvider {
|
||||
throw UnsupportedURLError();
|
||||
}
|
||||
var res = srcs.first;
|
||||
res.host = Uri.parse(url).host;
|
||||
res.hosts = [Uri.parse(url).host];
|
||||
res.hostChanged = true;
|
||||
return srcs.first;
|
||||
}
|
||||
AppSource? source;
|
||||
for (var s in sources.where((element) => element.host != null)) {
|
||||
for (var s in sources.where((element) => element.hosts.isNotEmpty)) {
|
||||
if (RegExp(
|
||||
'://${s.allowSubDomains ? '([^\\.]+\\.)*' : '(www\\.)?'}${s.host}(/|\\z)?')
|
||||
'://${s.allowSubDomains ? '([^\\.]+\\.)*' : '(www\\.)?'}(${getSourceRegex(s.hosts)})(/|\\z)?')
|
||||
.hasMatch(url)) {
|
||||
source = s;
|
||||
break;
|
||||
@@ -712,7 +716,7 @@ class SourceProvider {
|
||||
}
|
||||
if (source == null) {
|
||||
for (var s in sources.where(
|
||||
(element) => element.host == null && !element.neverAutoSelect)) {
|
||||
(element) => element.hosts.isEmpty && !element.neverAutoSelect)) {
|
||||
try {
|
||||
s.sourceSpecificStandardizeURL(url);
|
||||
source = s;
|
||||
|
Reference in New Issue
Block a user