mirror of
				https://github.com/ImranR98/Obtainium.git
				synced 2025-10-28 12:03:45 +01:00 
			
		
		
		
	Merge pull request #2273 from wodin/use-built-in-url-resolver
Use built-in method to fix HTML link resolution
This commit is contained in:
		| @@ -9,32 +9,7 @@ import 'package:obtainium/providers/apps_provider.dart'; | ||||
| import 'package:obtainium/providers/source_provider.dart'; | ||||
|  | ||||
| String ensureAbsoluteUrl(String ambiguousUrl, Uri referenceAbsoluteUrl) { | ||||
|   if (ambiguousUrl.startsWith('//')) { | ||||
|     ambiguousUrl = '${referenceAbsoluteUrl.scheme}:$ambiguousUrl'; | ||||
|   } | ||||
|   try { | ||||
|     Uri.parse(ambiguousUrl).origin; | ||||
|     return ambiguousUrl; | ||||
|   } catch (err) { | ||||
|     // is relative | ||||
|   } | ||||
|   var currPathSegments = referenceAbsoluteUrl.path | ||||
|       .split('/') | ||||
|       .where((element) => element.trim().isNotEmpty) | ||||
|       .toList(); | ||||
|   String absoluteUrl; | ||||
|   if (ambiguousUrl.startsWith('/')) { | ||||
|     absoluteUrl = '${referenceAbsoluteUrl.origin}$ambiguousUrl'; | ||||
|   } else if (currPathSegments.isEmpty) { | ||||
|     absoluteUrl = '${referenceAbsoluteUrl.origin}/$ambiguousUrl'; | ||||
|   } else if (ambiguousUrl.split('/').where((e) => e.isNotEmpty).length == 1) { | ||||
|     absoluteUrl = | ||||
|         '${referenceAbsoluteUrl.origin}/${currPathSegments.join('/')}/$ambiguousUrl'; | ||||
|   } else { | ||||
|     absoluteUrl = | ||||
|         '${referenceAbsoluteUrl.origin}/${currPathSegments.sublist(0, currPathSegments.length - (currPathSegments.last.contains('.') ? 1 : 0)).join('/')}/$ambiguousUrl'; | ||||
|   } | ||||
|   return Uri.parse(absoluteUrl).toString(); | ||||
|   return referenceAbsoluteUrl.resolve(ambiguousUrl).toString(); | ||||
| } | ||||
|  | ||||
| int compareAlphaNumeric(String a, String b) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user