mirror of
				https://github.com/ImranR98/Obtainium.git
				synced 2025-11-03 23:03:29 +01:00 
			
		
		
		
	Multi-host support + add '.net' host to APKPure source (#1250)
This commit is contained in:
		@@ -13,7 +13,7 @@ import 'package:url_launcher/url_launcher_string.dart';
 | 
			
		||||
 | 
			
		||||
class GitLab extends AppSource {
 | 
			
		||||
  GitLab() {
 | 
			
		||||
    host = 'gitlab.com';
 | 
			
		||||
    hosts = ['gitlab.com'];
 | 
			
		||||
    canSearch = true;
 | 
			
		||||
 | 
			
		||||
    sourceConfigSettingFormItems = [
 | 
			
		||||
@@ -52,12 +52,13 @@ class GitLab extends AppSource {
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  String sourceSpecificStandardizeURL(String url) {
 | 
			
		||||
    RegExp standardUrlRegEx = RegExp('^https?://(www\\.)?$host/[^/]+/[^/]+');
 | 
			
		||||
    RegExp standardUrlRegEx =
 | 
			
		||||
        RegExp('^https?://(www\\.)?${getSourceRegex(hosts)}/[^/]+/[^/]+');
 | 
			
		||||
    RegExpMatch? match = standardUrlRegEx.firstMatch(url.toLowerCase());
 | 
			
		||||
    if (match == null) {
 | 
			
		||||
      throw InvalidURLError(name);
 | 
			
		||||
    }
 | 
			
		||||
    return url.substring(0, match.end);
 | 
			
		||||
    return match.group(0)!;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  Future<String?> getPATIfAny(Map<String, dynamic> additionalSettings) async {
 | 
			
		||||
@@ -81,7 +82,7 @@ class GitLab extends AppSource {
 | 
			
		||||
  Future<Map<String, List<String>>> search(String query,
 | 
			
		||||
      {Map<String, dynamic> querySettings = const {}}) async {
 | 
			
		||||
    var url =
 | 
			
		||||
        'https://$host/api/v4/projects?search=${Uri.encodeQueryComponent(query)}';
 | 
			
		||||
        'https://${hosts[0]}/api/v4/projects?search=${Uri.encodeQueryComponent(query)}';
 | 
			
		||||
    var res = await sourceRequest(url);
 | 
			
		||||
    if (res.statusCode != 200) {
 | 
			
		||||
      throw getObtainiumHttpError(res);
 | 
			
		||||
@@ -89,7 +90,7 @@ class GitLab extends AppSource {
 | 
			
		||||
    var json = jsonDecode(res.body) as List<dynamic>;
 | 
			
		||||
    Map<String, List<String>> results = {};
 | 
			
		||||
    for (var element in json) {
 | 
			
		||||
      results['https://$host/${element['path_with_namespace']}'] = [
 | 
			
		||||
      results['https://${hosts[0]}/${element['path_with_namespace']}'] = [
 | 
			
		||||
        element['name_with_namespace'],
 | 
			
		||||
        element['description'] ?? tr('noDescription')
 | 
			
		||||
      ];
 | 
			
		||||
@@ -113,7 +114,7 @@ class GitLab extends AppSource {
 | 
			
		||||
    if (PAT != null) {
 | 
			
		||||
      var names = GitHub().getAppNames(standardUrl);
 | 
			
		||||
      Response res = await sourceRequest(
 | 
			
		||||
          'https://$host/api/v4/projects/${names.author}%2F${names.name}/releases?private_token=$PAT');
 | 
			
		||||
          'https://${hosts[0]}/api/v4/projects/${names.author}%2F${names.name}/releases?private_token=$PAT');
 | 
			
		||||
      if (res.statusCode != 200) {
 | 
			
		||||
        throw getObtainiumHttpError(res);
 | 
			
		||||
      }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user