Merge pull request #2497 from UlyssesZh/match-links-outside-a-tags

feat: add option to match links outside <a> tags even if links in <a> tags are found
This commit is contained in:
Imran
2025-08-31 00:00:20 -04:00
committed by GitHub
29 changed files with 37 additions and 1 deletions

View File

@@ -129,6 +129,8 @@ Future<List<MapEntry<String, String>>> grabLinksCommon(
Uri reqUrl,
Map<String, dynamic> additionalSettings,
) async {
bool matchLinksOutsideATags =
additionalSettings['matchLinksOutsideATags'] == true;
var html = parse(rawBody);
List<MapEntry<String, String>> allLinks = html
.querySelectorAll('a')
@@ -143,7 +145,7 @@ Future<List<MapEntry<String, String>>> grabLinksCommon(
.where((element) => element.key.isNotEmpty)
.map((e) => MapEntry(ensureAbsoluteUrl(e.key, reqUrl), e.value))
.toList();
if (allLinks.isEmpty) {
if (allLinks.isEmpty || matchLinksOutsideATags) {
allLinks = getLinksInLines(rawBody);
}
if (allLinks.isEmpty) {
@@ -247,6 +249,12 @@ class HTML extends AppSource {
];
var commonFormItems = [
[GeneratedFormSwitch('filterByLinkText', label: tr('filterByLinkText'))],
[
GeneratedFormSwitch(
'matchLinksOutsideATags',
label: tr('matchLinksOutsideATags')
),
],
[GeneratedFormSwitch('skipSort', label: tr('skipSort'))],
[GeneratedFormSwitch('reverseSort', label: tr('takeFirstLink'))],
[