From 436a6310d770ba374599053ba0fa0120612a8a97 Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Sun, 31 Dec 2023 15:59:44 -0500 Subject: [PATCH] Add www subdomain support for various sources (#1222) --- lib/app_sources/apkcombo.dart | 2 +- lib/app_sources/apkpure.dart | 2 +- lib/app_sources/codeberg.dart | 2 +- lib/app_sources/fdroid.dart | 5 +++-- lib/app_sources/github.dart | 2 +- lib/app_sources/gitlab.dart | 2 +- lib/app_sources/huaweiappgallery.dart | 2 +- lib/app_sources/mullvad.dart | 2 +- lib/app_sources/neutroncode.dart | 3 ++- lib/app_sources/sourceforge.dart | 5 +++-- lib/app_sources/sourcehut.dart | 2 +- 11 files changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/app_sources/apkcombo.dart b/lib/app_sources/apkcombo.dart index 73c144b..802373c 100644 --- a/lib/app_sources/apkcombo.dart +++ b/lib/app_sources/apkcombo.dart @@ -10,7 +10,7 @@ class APKCombo extends AppSource { @override String sourceSpecificStandardizeURL(String url) { - RegExp standardUrlRegEx = RegExp('^https?://$host/+[^/]+/+[^/]+'); + RegExp standardUrlRegEx = RegExp('^https?://(www\\.)?$host/+[^/]+/+[^/]+'); var match = standardUrlRegEx.firstMatch(url.toLowerCase()); if (match == null) { throw InvalidURLError(name); diff --git a/lib/app_sources/apkpure.dart b/lib/app_sources/apkpure.dart index a86fa0d..0fe3548 100644 --- a/lib/app_sources/apkpure.dart +++ b/lib/app_sources/apkpure.dart @@ -34,7 +34,7 @@ class APKPure extends AppSource { url = 'https://$host${Uri.parse(url).path}'; } RegExp standardUrlRegExA = - RegExp('^https?://$host/+[^/]+/+[^/]+(/+[^/]+)?'); + RegExp('^https?://(www\\.)?$host/+[^/]+/+[^/]+(/+[^/]+)?'); match = standardUrlRegExA.firstMatch(url.toLowerCase()); if (match == null) { throw InvalidURLError(name); diff --git a/lib/app_sources/codeberg.dart b/lib/app_sources/codeberg.dart index df06b9f..44a7bdf 100644 --- a/lib/app_sources/codeberg.dart +++ b/lib/app_sources/codeberg.dart @@ -16,7 +16,7 @@ class Codeberg extends AppSource { @override String sourceSpecificStandardizeURL(String url) { - RegExp standardUrlRegEx = RegExp('^https?://$host/[^/]+/[^/]+'); + RegExp standardUrlRegEx = RegExp('^https?://(www\\.)?$host/[^/]+/[^/]+'); RegExpMatch? match = standardUrlRegEx.firstMatch(url.toLowerCase()); if (match == null) { throw InvalidURLError(name); diff --git a/lib/app_sources/fdroid.dart b/lib/app_sources/fdroid.dart index 2d7d7a1..fdb7ddc 100644 --- a/lib/app_sources/fdroid.dart +++ b/lib/app_sources/fdroid.dart @@ -38,13 +38,14 @@ class FDroid extends AppSource { @override String sourceSpecificStandardizeURL(String url) { RegExp standardUrlRegExB = - RegExp('^https?://$host/+[^/]+/+packages/+[^/]+'); + RegExp('^https?://(www\\.)?$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?://$host/+packages/+[^/]+'); + RegExp standardUrlRegExA = + RegExp('^https?://(www\\.)?$host/+packages/+[^/]+'); match = standardUrlRegExA.firstMatch(url.toLowerCase()); if (match == null) { throw InvalidURLError(name); diff --git a/lib/app_sources/github.dart b/lib/app_sources/github.dart index 6ed69c8..5bc2801 100644 --- a/lib/app_sources/github.dart +++ b/lib/app_sources/github.dart @@ -149,7 +149,7 @@ class GitHub extends AppSource { @override String sourceSpecificStandardizeURL(String url) { - RegExp standardUrlRegEx = RegExp('^https?://$host/[^/]+/[^/]+'); + RegExp standardUrlRegEx = RegExp('^https?://(www\\.)?$host/[^/]+/[^/]+'); RegExpMatch? match = standardUrlRegEx.firstMatch(url.toLowerCase()); if (match == null) { throw InvalidURLError(name); diff --git a/lib/app_sources/gitlab.dart b/lib/app_sources/gitlab.dart index ae191f1..a0e8f14 100644 --- a/lib/app_sources/gitlab.dart +++ b/lib/app_sources/gitlab.dart @@ -52,7 +52,7 @@ class GitLab extends AppSource { @override String sourceSpecificStandardizeURL(String url) { - RegExp standardUrlRegEx = RegExp('^https?://$host/[^/]+/[^/]+'); + RegExp standardUrlRegEx = RegExp('^https?://(www\\.)?$host/[^/]+/[^/]+'); RegExpMatch? match = standardUrlRegEx.firstMatch(url.toLowerCase()); if (match == null) { throw InvalidURLError(name); diff --git a/lib/app_sources/huaweiappgallery.dart b/lib/app_sources/huaweiappgallery.dart index 76388e9..a073d2a 100644 --- a/lib/app_sources/huaweiappgallery.dart +++ b/lib/app_sources/huaweiappgallery.dart @@ -13,7 +13,7 @@ class HuaweiAppGallery extends AppSource { @override String sourceSpecificStandardizeURL(String url) { - RegExp standardUrlRegEx = RegExp('^https?://$host/app/[^/]+'); + RegExp standardUrlRegEx = RegExp('^https?://(www\\.)?$host/app/[^/]+'); RegExpMatch? match = standardUrlRegEx.firstMatch(url.toLowerCase()); if (match == null) { throw InvalidURLError(name); diff --git a/lib/app_sources/mullvad.dart b/lib/app_sources/mullvad.dart index 4e15d2f..ff9cefb 100644 --- a/lib/app_sources/mullvad.dart +++ b/lib/app_sources/mullvad.dart @@ -11,7 +11,7 @@ class Mullvad extends AppSource { @override String sourceSpecificStandardizeURL(String url) { - RegExp standardUrlRegEx = RegExp('^https?://$host'); + RegExp standardUrlRegEx = RegExp('^https?://(www\\.)?$host'); RegExpMatch? match = standardUrlRegEx.firstMatch(url.toLowerCase()); if (match == null) { throw InvalidURLError(name); diff --git a/lib/app_sources/neutroncode.dart b/lib/app_sources/neutroncode.dart index 4fbec3c..9ce0fdd 100644 --- a/lib/app_sources/neutroncode.dart +++ b/lib/app_sources/neutroncode.dart @@ -10,7 +10,8 @@ class NeutronCode extends AppSource { @override String sourceSpecificStandardizeURL(String url) { - RegExp standardUrlRegEx = RegExp('^https?://$host/downloads/file/[^/]+'); + RegExp standardUrlRegEx = + RegExp('^https?://(www\\.)?$host/downloads/file/[^/]+'); RegExpMatch? match = standardUrlRegEx.firstMatch(url.toLowerCase()); if (match == null) { throw InvalidURLError(name); diff --git a/lib/app_sources/sourceforge.dart b/lib/app_sources/sourceforge.dart index 3253926..885a9cc 100644 --- a/lib/app_sources/sourceforge.dart +++ b/lib/app_sources/sourceforge.dart @@ -10,13 +10,14 @@ class SourceForge extends AppSource { @override String sourceSpecificStandardizeURL(String url) { - RegExp standardUrlRegExB = RegExp('^https?://$host/p/[^/]+'); + RegExp standardUrlRegExB = RegExp('^https?://(www\\.)?$host/p/[^/]+'); RegExpMatch? match = standardUrlRegExB.firstMatch(url.toLowerCase()); if (match != null) { url = 'https://${Uri.parse(url.substring(0, match.end)).host}/projects/${url.substring(Uri.parse(url.substring(0, match.end)).host.length + '/projects/'.length + 1)}'; } - RegExp standardUrlRegExA = RegExp('^https?://$host/projects/[^/]+'); + RegExp standardUrlRegExA = + RegExp('^https?://(www\\.)?$host/projects/[^/]+'); match = standardUrlRegExA.firstMatch(url.toLowerCase()); if (match == null) { throw InvalidURLError(name); diff --git a/lib/app_sources/sourcehut.dart b/lib/app_sources/sourcehut.dart index d74fd7c..05b9959 100644 --- a/lib/app_sources/sourcehut.dart +++ b/lib/app_sources/sourcehut.dart @@ -20,7 +20,7 @@ class SourceHut extends AppSource { @override String sourceSpecificStandardizeURL(String url) { - RegExp standardUrlRegEx = RegExp('^https?://$host/[^/]+/[^/]+'); + RegExp standardUrlRegEx = RegExp('^https?://(www\\.)?$host/[^/]+/[^/]+'); RegExpMatch? match = standardUrlRegEx.firstMatch(url.toLowerCase()); if (match == null) { throw InvalidURLError(name);