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

@@ -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);