mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-07-21 00:29:42 +02:00
Bugfix for F-Droid URL parsing
This commit is contained in:
@@ -9,8 +9,14 @@ class FDroid implements AppSource {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String standardizeURL(String url) {
|
String standardizeURL(String url) {
|
||||||
RegExp standardUrlRegEx = RegExp('^https?://$host/[^/]+/packages/[^/]+');
|
RegExp standardUrlRegExB =
|
||||||
RegExpMatch? match = standardUrlRegEx.firstMatch(url.toLowerCase());
|
RegExp('^https?://$host/+[^/]+/+packages/+[^/]+');
|
||||||
|
RegExpMatch? match = standardUrlRegExB.firstMatch(url.toLowerCase());
|
||||||
|
if (match != null) {
|
||||||
|
url = 'https://$host/packages/${Uri.parse(url).pathSegments.last}';
|
||||||
|
}
|
||||||
|
RegExp standardUrlRegExA = RegExp('^https?://$host/+packages/+[^/]+');
|
||||||
|
match = standardUrlRegExA.firstMatch(url.toLowerCase());
|
||||||
if (match == null) {
|
if (match == null) {
|
||||||
throw notValidURL(runtimeType.toString());
|
throw notValidURL(runtimeType.toString());
|
||||||
}
|
}
|
||||||
|
@@ -52,7 +52,7 @@ class _AddAppPageState extends State<AddAppPage> {
|
|||||||
sourceProvider
|
sourceProvider
|
||||||
.getSource(value ?? '')
|
.getSource(value ?? '')
|
||||||
.standardizeURL(
|
.standardizeURL(
|
||||||
makeUrlHttps(
|
preStandardizeUrl(
|
||||||
value ?? ''));
|
value ?? ''));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return e is String
|
return e is String
|
||||||
|
@@ -96,7 +96,7 @@ escapeRegEx(String s) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
makeUrlHttps(String url) {
|
preStandardizeUrl(String url) {
|
||||||
if (url.toLowerCase().indexOf('http://') != 0 &&
|
if (url.toLowerCase().indexOf('http://') != 0 &&
|
||||||
url.toLowerCase().indexOf('https://') != 0) {
|
url.toLowerCase().indexOf('https://') != 0) {
|
||||||
url = 'https://$url';
|
url = 'https://$url';
|
||||||
@@ -159,7 +159,7 @@ class SourceProvider {
|
|||||||
List<MassAppSource> massSources = [GitHubStars()];
|
List<MassAppSource> massSources = [GitHubStars()];
|
||||||
|
|
||||||
AppSource getSource(String url) {
|
AppSource getSource(String url) {
|
||||||
url = makeUrlHttps(url);
|
url = preStandardizeUrl(url);
|
||||||
AppSource? source;
|
AppSource? source;
|
||||||
for (var s in sources) {
|
for (var s in sources) {
|
||||||
if (url.toLowerCase().contains('://${s.host}')) {
|
if (url.toLowerCase().contains('://${s.host}')) {
|
||||||
@@ -186,7 +186,7 @@ class SourceProvider {
|
|||||||
|
|
||||||
Future<App> getApp(AppSource source, String url, List<String> additionalData,
|
Future<App> getApp(AppSource source, String url, List<String> additionalData,
|
||||||
{String customName = ''}) async {
|
{String customName = ''}) async {
|
||||||
String standardUrl = source.standardizeURL(makeUrlHttps(url));
|
String standardUrl = source.standardizeURL(preStandardizeUrl(url));
|
||||||
AppNames names = source.getAppNames(standardUrl);
|
AppNames names = source.getAppNames(standardUrl);
|
||||||
APKDetails apk =
|
APKDetails apk =
|
||||||
await source.getLatestAPKDetails(standardUrl, additionalData);
|
await source.getLatestAPKDetails(standardUrl, additionalData);
|
||||||
|
Reference in New Issue
Block a user