Added an (experimental) Source override option for URLs that work with an existing Source but use a custom host (#271, #393) (#502)

This commit is contained in:
Imran Remtulla
2023-04-29 23:50:12 -04:00
committed by GitHub
parent 3e4d5c26ac
commit 392554123b
32 changed files with 270 additions and 158 deletions

View File

@@ -31,7 +31,7 @@ class APKMirror extends AppSource {
}
@override
String standardizeURL(String url) {
String sourceSpecificStandardizeURL(String url) {
RegExp standardUrlRegEx = RegExp('^https?://$host/apk/[^/]+/[^/]+');
RegExpMatch? match = standardUrlRegEx.firstMatch(url.toLowerCase());
if (match == null) {

View File

@@ -39,7 +39,7 @@ class Codeberg extends AppSource {
var gh = GitHub();
@override
String standardizeURL(String url) {
String sourceSpecificStandardizeURL(String url) {
RegExp standardUrlRegEx = RegExp('^https?://$host/[^/]+/[^/]+');
RegExpMatch? match = standardUrlRegEx.firstMatch(url.toLowerCase());
if (match == null) {

View File

@@ -12,16 +12,15 @@ class FDroid extends AppSource {
}
@override
String standardizeURL(String url) {
String sourceSpecificStandardizeURL(String url) {
RegExp standardUrlRegExB =
RegExp('^https?://(cloudflare\\.)?$host/+[^/]+/+packages/+[^/]+');
RegExp('^https?://$host/+[^/]+/+packages/+[^/]+');
RegExpMatch? match = standardUrlRegExB.firstMatch(url.toLowerCase());
if (match != null) {
url =
'https://${Uri.parse(url.substring(0, match.end)).host}/packages/${Uri.parse(url).pathSegments.last}';
}
RegExp standardUrlRegExA =
RegExp('^https?://(cloudflare\\.)?$host/+packages/+[^/]+');
RegExp standardUrlRegExA = RegExp('^https?://$host/+packages/+[^/]+');
match = standardUrlRegExA.firstMatch(url.toLowerCase());
if (match == null) {
throw InvalidURLError(name);

View File

@@ -19,17 +19,6 @@ class FDroidRepo extends AppSource {
];
}
@override
String standardizeURL(String url) {
RegExp standardUrlRegExp =
RegExp('^https?://.+/fdroid/([^/]+(/|\\?)|[^/]+\$)');
RegExpMatch? match = standardUrlRegExp.firstMatch(url.toLowerCase());
if (match == null) {
throw InvalidURLError(name);
}
return url.substring(0, match.end);
}
@override
Future<APKDetails> getLatestAPKDetails(
String standardUrl,

View File

@@ -75,7 +75,7 @@ class GitHub extends AppSource {
}
@override
String standardizeURL(String url) {
String sourceSpecificStandardizeURL(String url) {
RegExp standardUrlRegEx = RegExp('^https?://$host/[^/]+/[^/]+');
RegExpMatch? match = standardUrlRegEx.firstMatch(url.toLowerCase());
if (match == null) {

View File

@@ -19,7 +19,7 @@ class GitLab extends AppSource {
}
@override
String standardizeURL(String url) {
String sourceSpecificStandardizeURL(String url) {
RegExp standardUrlRegEx = RegExp('^https?://$host/[^/]+/[^/]+');
RegExpMatch? match = standardUrlRegEx.firstMatch(url.toLowerCase());
if (match == null) {

View File

@@ -6,7 +6,7 @@ import 'package:obtainium/providers/source_provider.dart';
class HTML extends AppSource {
@override
String standardizeURL(String url) {
String sourceSpecificStandardizeURL(String url) {
return url;
}

View File

@@ -9,7 +9,7 @@ class IzzyOnDroid extends AppSource {
}
@override
String standardizeURL(String url) {
String sourceSpecificStandardizeURL(String url) {
RegExp standardUrlRegEx = RegExp('^https?://$host/repo/apk/[^/]+');
RegExpMatch? match = standardUrlRegEx.firstMatch(url.toLowerCase());
if (match == null) {

View File

@@ -10,7 +10,7 @@ class Mullvad extends AppSource {
}
@override
String standardizeURL(String url) {
String sourceSpecificStandardizeURL(String url) {
RegExp standardUrlRegEx = RegExp('^https?://$host');
RegExpMatch? match = standardUrlRegEx.firstMatch(url.toLowerCase());
if (match == null) {

View File

@@ -9,7 +9,7 @@ class NeutronCode extends AppSource {
}
@override
String standardizeURL(String url) {
String sourceSpecificStandardizeURL(String url) {
RegExp standardUrlRegEx = RegExp('^https?://$host/downloads/file/[^/]+');
RegExpMatch? match = standardUrlRegEx.firstMatch(url.toLowerCase());
if (match == null) {

View File

@@ -9,7 +9,7 @@ class Signal extends AppSource {
}
@override
String standardizeURL(String url) {
String sourceSpecificStandardizeURL(String url) {
return 'https://$host';
}

View File

@@ -9,7 +9,7 @@ class SourceForge extends AppSource {
}
@override
String standardizeURL(String url) {
String sourceSpecificStandardizeURL(String url) {
RegExp standardUrlRegEx = RegExp('^https?://$host/projects/[^/]+');
RegExpMatch? match = standardUrlRegEx.firstMatch(url.toLowerCase());
if (match == null) {

View File

@@ -20,7 +20,7 @@ class SteamMobile extends AppSource {
final apks = {'steam': tr('steamMobile'), 'steam-chat-app': tr('steamChat')};
@override
String standardizeURL(String url) {
String sourceSpecificStandardizeURL(String url) {
return 'https://$host';
}

View File

@@ -11,7 +11,7 @@ class TelegramApp extends AppSource {
}
@override
String standardizeURL(String url) {
String sourceSpecificStandardizeURL(String url) {
return 'https://$host';
}

View File

@@ -10,7 +10,7 @@ class VLC extends AppSource {
}
@override
String standardizeURL(String url) {
String sourceSpecificStandardizeURL(String url) {
return 'https://$host';
}

View File

@@ -9,7 +9,7 @@ class WhatsApp extends AppSource {
}
@override
String standardizeURL(String url) {
String sourceSpecificStandardizeURL(String url) {
return 'https://$host';
}