mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-07-22 17:19:42 +02:00
URL parsing bugfix for HTML source (#1253)
This commit is contained in:
@@ -17,13 +17,17 @@ String ensureAbsoluteUrl(String ambiguousUrl, Uri referenceAbsoluteUrl) {
|
|||||||
.split('/')
|
.split('/')
|
||||||
.where((element) => element.trim().isNotEmpty)
|
.where((element) => element.trim().isNotEmpty)
|
||||||
.toList();
|
.toList();
|
||||||
|
String absoluteUrl;
|
||||||
if (ambiguousUrl.startsWith('/') || currPathSegments.isEmpty) {
|
if (ambiguousUrl.startsWith('/') || currPathSegments.isEmpty) {
|
||||||
return '${referenceAbsoluteUrl.origin}/$ambiguousUrl';
|
absoluteUrl = '${referenceAbsoluteUrl.origin}/$ambiguousUrl';
|
||||||
} else if (ambiguousUrl.split('/').where((e) => e.isNotEmpty).length == 1) {
|
} else if (ambiguousUrl.split('/').where((e) => e.isNotEmpty).length == 1) {
|
||||||
return '${referenceAbsoluteUrl.origin}/${currPathSegments.join('/')}/$ambiguousUrl';
|
absoluteUrl =
|
||||||
|
'${referenceAbsoluteUrl.origin}/${currPathSegments.join('/')}/$ambiguousUrl';
|
||||||
} else {
|
} else {
|
||||||
return '${referenceAbsoluteUrl.origin}/${currPathSegments.sublist(0, currPathSegments.length - (currPathSegments.last.contains('.') ? 1 : 0)).join('/')}/$ambiguousUrl';
|
absoluteUrl =
|
||||||
|
'${referenceAbsoluteUrl.origin}/${currPathSegments.sublist(0, currPathSegments.length - (currPathSegments.last.contains('.') ? 1 : 0)).join('/')}/$ambiguousUrl';
|
||||||
}
|
}
|
||||||
|
return Uri.parse(absoluteUrl).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
int compareAlphaNumeric(String a, String b) {
|
int compareAlphaNumeric(String a, String b) {
|
||||||
@@ -172,6 +176,8 @@ class HTML extends AppSource {
|
|||||||
? element.text
|
? element.text
|
||||||
: (element.attributes['href'] ?? '').split('/').last))
|
: (element.attributes['href'] ?? '').split('/').last))
|
||||||
.where((element) => element.key.isNotEmpty)
|
.where((element) => element.key.isNotEmpty)
|
||||||
|
.map((e) =>
|
||||||
|
MapEntry(ensureAbsoluteUrl(e.key, res.request!.url), e.value))
|
||||||
.toList();
|
.toList();
|
||||||
if (allLinks.isEmpty) {
|
if (allLinks.isEmpty) {
|
||||||
allLinks = RegExp(
|
allLinks = RegExp(
|
||||||
|
Reference in New Issue
Block a user