From e1980f4de205a847ce2b588a5b72236e9144b3b8 Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Wed, 3 May 2023 17:49:50 -0400 Subject: [PATCH] SourceForge URL flexibility (#525) --- lib/app_sources/sourceforge.dart | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/app_sources/sourceforge.dart b/lib/app_sources/sourceforge.dart index 2d976ea..ee2f22b 100644 --- a/lib/app_sources/sourceforge.dart +++ b/lib/app_sources/sourceforge.dart @@ -10,8 +10,14 @@ class SourceForge extends AppSource { @override String sourceSpecificStandardizeURL(String url) { - RegExp standardUrlRegEx = RegExp('^https?://$host/projects/[^/]+'); - RegExpMatch? match = standardUrlRegEx.firstMatch(url.toLowerCase()); + RegExp standardUrlRegExB = RegExp('^https?://$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/[^/]+'); + match = standardUrlRegExA.firstMatch(url.toLowerCase()); if (match == null) { throw InvalidURLError(name); }